Bug 109617

Summary: Teach more WTF string classes about vectors with inline capacity
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: New BugsAssignee: Eric Seidel (no email) <eric>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, andersca, benjamin, cmarcelo, darin, jochen, msaboff, ojan.autocc, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 109619, 109638, 109708    
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Eric Seidel (no email) 2013-02-12 14:44:00 PST
Teach more WTF string classes about vectors with inline capacity
Comment 1 Eric Seidel (no email) 2013-02-12 14:46:31 PST
Created attachment 187940 [details]
Patch
Comment 2 Benjamin Poulain 2013-02-12 14:56:14 PST
Comment on attachment 187940 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=187940&action=review

> Source/WTF/ChangeLog:9
> +        I'm about to deploy these all over the HTML/WebVTT parser code
> +        to make our string creation much less verbose.

Let's explain the changes here instead!

> Source/WTF/wtf/text/AtomicString.h:67
> +
> +    template<size_t inlineCapacity>
> +    explicit AtomicString(Vector<UChar, inlineCapacity> characters)
> +        : m_string(add(characters.data(), characters.size()))
> +    {
> +    }
> +

This is in the middle of the two constructor from literal.
I would instead put this close to the constructors taking a UChar*
Comment 3 Eric Seidel (no email) 2013-02-12 15:02:32 PST
Created attachment 187946 [details]
Patch for landing
Comment 4 WebKit Review Bot 2013-02-12 16:42:43 PST
Comment on attachment 187946 [details]
Patch for landing

Clearing flags on attachment: 187946

Committed r142689: <http://trac.webkit.org/changeset/142689>
Comment 5 WebKit Review Bot 2013-02-12 16:42:47 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Darin Adler 2013-02-13 09:46:37 PST
Comment on attachment 187946 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=187946&action=review

> Source/WTF/wtf/text/AtomicString.h:53
> +    explicit AtomicString(Vector<UChar, inlineCapacity> characters)

This is bad for performance. It copies the vector before creating the atomic string! Please use const Vector& instead of Vector as the argument type.

> Source/WTF/wtf/text/StringImpl.h:358
> +    static PassRefPtr<StringImpl> create8BitIfPossible(Vector<UChar, inlineCapacity> vector)

Same problem here.
Comment 7 Eric Seidel (no email) 2013-02-13 09:48:52 PST
Comment on attachment 187946 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=187946&action=review

>> Source/WTF/wtf/text/AtomicString.h:53
>> +    explicit AtomicString(Vector<UChar, inlineCapacity> characters)
> 
> This is bad for performance. It copies the vector before creating the atomic string! Please use const Vector& instead of Vector as the argument type.

Ouch!  Yes. Fixing now.
Comment 8 Eric Seidel (no email) 2013-02-13 10:06:14 PST
Comment on attachment 187946 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=187946&action=review

>>> Source/WTF/wtf/text/AtomicString.h:53
>>> +    explicit AtomicString(Vector<UChar, inlineCapacity> characters)
>> 
>> This is bad for performance. It copies the vector before creating the atomic string! Please use const Vector& instead of Vector as the argument type.
> 
> Ouch!  Yes. Fixing now.

Fixed: bug 109708.

In doing this I found that wtf/dota/ uses Vector<char> as an argument all over the place!  I suspect it was re-written on top of WTF from stl w/o realizing this.  I've filed bug 109709.