Index: Source/core/editing/iterators/TextIterator.cpp |
diff --git a/Source/core/editing/iterators/TextIterator.cpp b/Source/core/editing/iterators/TextIterator.cpp |
index 0c9aa7edc6b851be5426c5e81f8d33c49afe9bb8..8f602548718493f4e5b9a6f64db96e6ea9fd21b7 100644 |
--- a/Source/core/editing/iterators/TextIterator.cpp |
+++ b/Source/core/editing/iterators/TextIterator.cpp |
@@ -1093,16 +1093,19 @@ static String createPlainText(const EphemeralRangeTemplate<Strategy>& range, Tex |
return emptyString(); |
TextIteratorAlgorithm<Strategy> it(range.startPosition(), range.endPosition(), behavior); |
- // The initial buffer size can be critical for performance: https://bugs.webkit.org/show_bug.cgi?id=81192 |
- static const unsigned initialCapacity = 1 << 15; |
unsigned bufferLength = 0; |
StringBuilder builder; |
- builder.reserveCapacity(initialCapacity); |
+ if (!it.atEnd()) { |
yosin_UTC9
2015/08/26 01:23:21
Can we use early return pattern?
if (it.atEnd())
sof
2015/08/26 06:32:21
That looks better, switched to an early return.
|
+ // The initial buffer size can be critical for performance: https://bugs.webkit.org/show_bug.cgi?id=81192 |
+ static const unsigned initialCapacity = 1 << 15; |
- for (; !it.atEnd(); it.advance()) { |
- it.text().appendTextToStringBuilder(builder); |
- bufferLength += it.length(); |
+ builder.reserveCapacity(initialCapacity); |
+ |
+ for (; !it.atEnd(); it.advance()) { |
+ it.text().appendTextToStringBuilder(builder); |
+ bufferLength += it.length(); |
yosin_UTC9
2015/08/26 01:23:21
Optional: Do we need to sum result length up?
It s
sof
2015/08/26 06:32:21
Just testing for builder.isEmpty() here would suff
|
+ } |
} |
if (!bufferLength) |