[webkit-dev] Initializing String and AtomicString with literals
Adam Barth
abarth at webkit.org
Fri Aug 24 22:05:28 PDT 2012
Thanks! The wiki page is very helpful. I wonder if we should
organize a hack-a-thon to deploy this pattern throughout WebKit. Is
there a way the compiler could give us a list of all the code location
we should update?
Adam
On Fri, Aug 24, 2012 at 8:00 PM, Benjamin Poulain <benjamin at webkit.org> wrote:
> Dear webkit-dev,
>
>
> Some recent changes improved the way we can use string classes with
> literals.
>
> There are 3 new constructors for initializing a string from a literal:
> -String(ASCIILIteral):
> http://trac.webkit.org/browser/trunk/Source/WTF/wtf/text/WTFString.h#L139
> -String(const char[], ConstructFromLiteralTag)
> -AtomicString(const char[], ConstructFromLiteralTag)
>
> The differences with the regular char* constructor are:
> -no memory is allocated for the bytes of the string.
> -the characters are not copied to the heap
> -String(const char[], ConstructFromLiteralTag) does not even access the
> bytes of the string.
>
> Those constructors are faster and use less memory in some cases.
> I converted some of the generated code to use the new constructors. In the
> future, please consider using ASCIILiteral() whenever constructing a String,
> and ConstructFromLiteral for a AtomicString.
>
> cheers,
> Benjamin
>
> PS: I started a Wiki page about the efficient use of the string classes:
> http://trac.webkit.org/wiki/EfficientStrings
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-dev
>
More information about the webkit-dev
mailing list