⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changes between Version 5 and Version 6 of EfficientStrings


Ignore:
Timestamp:
Aug 29, 2012, 1:56:25 AM (14 years ago)
Author:
kenneth@webkit.org
Comment:

Some more hints

Legend:

Unmodified
Added
Removed
Modified
  • EfficientStrings

    v5 v6  
    1111The safest option is ''ASCIILiteral("Foo")''. It produces the same code size as String("Foo") while being faster.
    1212
    13 The difference between the version is if the length of the string is included or not. Having the size given in the constructor makes the constructor faster. Having the size also makes the code bigger, which is a problem when the code is executed infrequently.[[BR]]
     13The difference between the version is if the length of the string is included or not. Having the size given in the constructor makes the constructor faster. Having the size also makes the code bigger, which is a problem when the code is executed infrequently.[[BR]][[BR]]
    1414In general, use ASCIILiteral unless you can show improvement on a benchmark by using ConstructFromLiteral.
    1515
    … …  
    2121 * foo.startsWith(ASCIILiteral("bar"))
    2222 * foo.startsWith(String("bar"))
     23
    2324The first version is the fastest.
    2425
    … …  
    3233{{{
    3334str = text;
    34 str.append("a"); // == str.append(String("a");
     35str.append("a"); // == str.append(String("a"));
    3536str.append(foo);
    3637str += bar;
    3738}}}
     39
    3840Should be (StringOperators):
     41
    3942{{{
    4043str = text + 'a' + foo + bar;
    4144}}}
    4245
     46Note the use of {{{ 'a' }}} here instead of {{{ "a" }}} as it is more efficient.
    4347----
    4448
    … …  
    5054   str += "bar";
    5155}}}
     56
    5257should be:
    5358
    … …  
    5964str = builder.toString();
    6065}}}
     66
     67Note: If you need to append a literal char, {{{ builder.append('c'); }}} is more efficient than {{{ builder.appendLiteral("c"); }}}