[webkit-reviews] review requested: [Bug 67079] Replace usages of Vector<UChar> with existing StringBuilder : [Attachment 105574] patch v3

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 29 21:38:27 PDT 2011


Xianzhu Wang <wangxianzhu at chromium.org> has asked  for review:
Bug 67079: Replace usages of Vector<UChar> with existing StringBuilder
https://bugs.webkit.org/show_bug.cgi?id=67079

Attachment 105574: patch v3
https://bugs.webkit.org/attachment.cgi?id=105574&action=review

------- Additional Comments from Xianzhu Wang <wangxianzhu at chromium.org>
Thanks Gavin and Darin for review!

> This patch looks good, would be great to be able to remove the String::adopt
method, do you know how far this takes us in that direction?
I think this patch has replaced more than 80% Vector<UChar> usages and almost
all String::adopt usages. The remaining places depend on other bugs blocking
bug 66661 and will be fixed soon.

>> Source/WebCore/platform/text/TextStream.cpp:87
>>	size_t stringLength = strlen(string);
> 
> I think this function should just be
> { m_text.append(string); return *this; }
> 
> (If the StringBuilder needs to grow the buffer it should be checking for
overflow itself).

Done.

>> Source/WebCore/xml/parser/CharacterReferenceParserInlineMethods.h:47
>> +	   
source.prepend(SegmentedString(String(consumedCharacters.characters(),
consumedCharacters.length())));
> 
> To get the current contents of a StringBuilder as a String you could call
> consumedCharacters.toString()
> (or maybe consumedCharacters.toStringPreserveCapacity() )
> instead of "String(consumedCharacters.characters(),
consumedCharacters.length())".

For now both toString() and toStringPreserveCapacity() alters the internal
state and are non-const. They can't be used here because consumedCharacters is
const.
My plan is to make toStringPreserveCapacity() const (also make
StringBuilder::m_string mutable). This will be done in bug 67081.


More information about the webkit-reviews mailing list