Bug 109617 - Teach more WTF string classes about vectors with inline capacity
Summary: Teach more WTF string classes about vectors with inline capacity
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Seidel (no email)
URL:
Keywords:
Depends on:
Blocks: 109619 109638 109708
  Show dependency treegraph
 
Reported: 2013-02-12 14:44 PST by Eric Seidel (no email)
Modified: 2013-02-13 10:06 PST (History)
9 users (show)

See Also:


Attachments
Patch (3.97 KB, patch)
2013-02-12 14:46 PST, Eric Seidel (no email)
no flags Details | Formatted Diff | Diff
Patch for landing (4.86 KB, patch)
2013-02-12 15:02 PST, Eric Seidel (no email)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.