Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Issue 1647483003: Introduce TextBuffer as Output Type of copyTextTo() for Text Iterators (Closed)

Created:
4 years, 10 months ago by Xiaocheng
Modified:
4 years, 10 months ago
Reviewers:
yosin_UTC9
CC:
blink-reviews, chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Introduce TextBuffer as Output Type of copyTextTo() for Text Iterators For backwards text iterators, their |copyTextTo()| function prepends text to the output buffer. It causes performance issues when repeatedly prepending to vectors. This CL introduces TextBuffer as the output class of |copyTextTo()|. The new class wraps |WTF::Vector|, and can grow either forwards or backwards according to its template parameter. It ensures linear time complexity of |copyTextTo()| regardless of the direction of the text iterator. This is part of a bigger CL [1]. [1] https://codereview.chromium.org/1604783002 BUG=n/a

Patch Set 1 #

Total comments: 18

Patch Set 2 : Switch from Template to Inheritance #

Total comments: 8

Patch Set 3 : #

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+296 lines, -112 lines) Patch
M third_party/WebKit/Source/core/core.gypi View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/VisibleUnits.cpp View 1 2 6 chunks +16 lines, -16 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/CharacterIterator.h View 1 chunk +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/CharacterIterator.cpp View 1 chunk +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/SearchBuffer.cpp View 2 chunks +5 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.h View 1 3 chunks +5 lines, -25 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp View 1 2 1 chunk +35 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIteratorTest.cpp View 3 chunks +18 lines, -18 lines 0 comments Download
A third_party/WebKit/Source/core/editing/iterators/TextBuffer.h View 1 2 1 chunk +72 lines, -0 lines 7 comments Download
A third_party/WebKit/Source/core/editing/iterators/TextBuffer.cpp View 1 2 1 chunk +67 lines, -0 lines 2 comments Download
M third_party/WebKit/Source/core/editing/iterators/TextIterator.h View 1 2 chunks +4 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp View 1 chunk +20 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp View 2 chunks +16 lines, -16 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.h View 2 chunks +2 lines, -19 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/TextIteratorTextState.cpp View 1 2 1 chunk +25 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/iterators/WordAwareIterator.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/web/mac/WebSubstringUtil.mm View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 10 (3 generated)
Xiaocheng
PTAL.
4 years, 10 months ago (2016-01-28 01:54:39 UTC) #4
yosin_UTC9
https://codereview.chromium.org/1647483003/diff/1/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp File third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp (right): https://codereview.chromium.org/1647483003/diff/1/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp#newcode437 third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp:437: if (m_singleCharacterBuffer) { We prefer early return style, e.g.: ...
4 years, 10 months ago (2016-01-28 04:28:21 UTC) #5
Xiaocheng
Thanks for the review. PTAL at Patch 2. https://codereview.chromium.org/1647483003/diff/1/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp File third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp (right): https://codereview.chromium.org/1647483003/diff/1/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp#newcode437 third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp:437: if ...
4 years, 10 months ago (2016-01-28 07:04:05 UTC) #6
yosin_UTC9
https://codereview.chromium.org/1647483003/diff/20001/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp File third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp (right): https://codereview.chromium.org/1647483003/diff/20001/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp#newcode438 third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp:438: output.pushCharacter(m_singleCharacterBuffer, 1); nit: s/pushCharacter/pushCharacters/ https://codereview.chromium.org/1647483003/diff/20001/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp#newcode442 third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp:442: if (m_textContainer.is8Bit()) nit: ...
4 years, 10 months ago (2016-01-28 07:41:13 UTC) #7
Xiaocheng
PTAL at Patch 3. https://codereview.chromium.org/1647483003/diff/20001/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp File third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp (right): https://codereview.chromium.org/1647483003/diff/20001/third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp#newcode438 third_party/WebKit/Source/core/editing/iterators/SimplifiedBackwardsTextIterator.cpp:438: output.pushCharacter(m_singleCharacterBuffer, 1); On 2016/01/28 at ...
4 years, 10 months ago (2016-01-28 08:47:36 UTC) #8
yosin_UTC9
Please split this patch into N 1. Introduce ForwardsTextBuffer and BackwardsTextBuffer w/ tests 2. Utilizing ...
4 years, 10 months ago (2016-01-28 09:06:17 UTC) #9
Xiaocheng
4 years, 10 months ago (2016-01-28 10:26:12 UTC) #10
On 2016/01/28 at 09:06:17, yosin wrote:
> Please split this patch into N
> 1. Introduce ForwardsTextBuffer and BackwardsTextBuffer w/ tests
> 2. Utilizing *TextBuffer in backward iterator
> 3. Utilizing *TextBuffer in text iterator
> 4. ....
> 
> In other words, this patch is all-in-one patch.
> 

OK... (╯°Д°)╯︵ ┻━┻

>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> File third_party/WebKit/Source/core/editing/iterators/TextBuffer.cpp (right):
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.cpp:21: UChar*
TextBufferBase::pushInternal(size_t length)
> s/pushInternal/ensureDestination/ or another, this function allocates
destination in buffer.
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.cpp:25: UChar* ans
= pushDestination(length);
> nit: s/pushDestination/computeDestination/ or another. It doesn't add data, it
returns destination.
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> File third_party/WebKit/Source/core/editing/iterators/TextBuffer.h (right):
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:9: #include
"wtf/text/WTFString.h"
> nit: #include "wtf/Vector.h"
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:14:
STACK_ALLOCATED();
>  WTF_MAKE_NONCOPYABLE(TextBufferBase) see wtf/Noncopyable.h
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:16:
TextBufferBase();
> nit: |TextBufferBase()| ctor should be protected.
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:39: virtual void
shiftData(size_t oldCapacity) {}
> nit: Don't inline virtual function.
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:46:
STACK_ALLOCATED();
>  WTF_MAKE_NONCOPYABLE(ForwardsTextBuffer) see wtf/Noncopyable.h
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:51: using
TextBufferBase::m_size;
> nit: We should use protected member function instead of accessing member
variable in base class.
> 
>
https://codereview.chromium.org/1647483003/diff/40001/third_party/WebKit/Sour...
> third_party/WebKit/Source/core/editing/iterators/TextBuffer.h:58:
STACK_ALLOCATED();
>  WTF_MAKE_NONCOPYABLE(BackwardsTextBuffer) see wtf/Noncopyable.h

Powered by Google App Engine
This is Rietveld 408576698