Changes between Version 5 and Version 6 of EfficientStrings
- Timestamp:
- Aug 29, 2012 1:56:25 AM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
EfficientStrings
v5 v6 11 11 The safest option is ''ASCIILiteral("Foo")''. It produces the same code size as String("Foo") while being faster. 12 12 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]] 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]][[BR]] 14 14 In general, use ASCIILiteral unless you can show improvement on a benchmark by using ConstructFromLiteral. 15 15 … … 21 21 * foo.startsWith(ASCIILiteral("bar")) 22 22 * foo.startsWith(String("bar")) 23 23 24 The first version is the fastest. 24 25 … … 32 33 {{{ 33 34 str = text; 34 str.append("a"); // == str.append(String("a") ;35 str.append("a"); // == str.append(String("a")); 35 36 str.append(foo); 36 37 str += bar; 37 38 }}} 39 38 40 Should be (StringOperators): 41 39 42 {{{ 40 43 str = text + 'a' + foo + bar; 41 44 }}} 42 45 46 Note the use of {{{ 'a' }}} here instead of {{{ "a" }}} as it is more efficient. 43 47 ---- 44 48 … … 50 54 str += "bar"; 51 55 }}} 56 52 57 should be: 53 58 … … 59 64 str = builder.toString(); 60 65 }}} 66 67 Note: If you need to append a literal char, {{{ builder.append('c'); }}} is more efficient than {{{ builder.appendLiteral("c"); }}}