[Webkit-unassigned] [Bug 67079] Replace usages of Vector<UChar> with existing StringBuilder

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 29 20:30:34 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=67079


Gavin Barraclough <barraclough at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #105476|review?                     |review-
               Flag|                            |




--- Comment #8 from Gavin Barraclough <barraclough at apple.com>  2011-08-29 20:30:34 PST ---
(From update of attachment 105476)
View in context: https://bugs.webkit.org/attachment.cgi?id=105476&action=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?
r- for a couple of small issues, but generally looks fine to me.

> 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).

> Source/WebCore/storage/IDBLevelDBCoding.cpp:275
> +        result.append(static_cast<UChar>((hi << 8) | lo));

Errrrk! – this looks like a(n existing) bug!
'hi' is an unsigned char, but is left shifted by 8.
You can probably fix this like this:

result.append((static_cast<UChar>(hi) << 8) | lo);

> 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())".

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list