[webkit-dev] Initializing String and AtomicString with literals

Maciej Stachowiak mjs at apple.com
Fri Aug 24 22:13:40 PDT 2012


What's the difference between the ASCIILiteral and ConstructFromLiteral versions?

 - Maciej

On 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20120824/a5cd7af3/attachment.html>


More information about the webkit-dev mailing list