| 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..017f40923f6673800e119b81a2df474b6d0d0404 100644
|
| --- a/Source/core/editing/iterators/TextIterator.cpp
|
| +++ b/Source/core/editing/iterators/TextIterator.cpp
|
| @@ -1093,19 +1093,20 @@ static String createPlainText(const EphemeralRangeTemplate<Strategy>& range, Tex
|
| return emptyString();
|
|
|
| TextIteratorAlgorithm<Strategy> it(range.startPosition(), range.endPosition(), behavior);
|
| +
|
| + if (it.atEnd())
|
| + return emptyString();
|
| +
|
| // 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);
|
|
|
| - for (; !it.atEnd(); it.advance()) {
|
| + for (; !it.atEnd(); it.advance())
|
| it.text().appendTextToStringBuilder(builder);
|
| - bufferLength += it.length();
|
| - }
|
|
|
| - if (!bufferLength)
|
| + if (builder.isEmpty())
|
| return emptyString();
|
|
|
| return builder.toString();
|
|
|