| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class StringBase { | 5 class StringBase { |
| 6 // TODO(jmesserly): this array copy is really unfortunate | 6 // TODO(jmesserly): this array copy is really unfortunate |
| 7 // TODO(jmesserly): check the performance of String.fromCharCode.apply | 7 // TODO(jmesserly): check the performance of String.fromCharCode.apply |
| 8 // TODO(jmesserly): fix the generated JS name of factory ctors, | 8 // TODO(jmesserly): fix the generated JS name of factory ctors, |
| 9 // they shouldn't be duplicating the name. | 9 // they shouldn't be duplicating the name. |
| 10 static String createFromCharCodes(List<int> charCodes) native @''' | 10 static String createFromCharCodes(List<int> charCodes) native @''' |
| 11 if (Object.getPrototypeOf(charCodes) !== Array.prototype) { | 11 if (Object.getPrototypeOf(charCodes) !== Array.prototype) { |
| 12 charCodes = new ListFactory.ListFactory$from$factory(charCodes); | 12 charCodes = new ListFactory.ListFactory$from$factory(charCodes); |
| 13 } | 13 } |
| 14 return String.fromCharCode.apply(null, charCodes); | 14 return String.fromCharCode.apply(null, charCodes); |
| 15 ''' { | 15 ''' { |
| 16 // we may need to iterate over charCodes |
| 17 var i = charCodes.iterator(); i.next(); i.hasNext(); |
| 16 new ListFactory.from(charCodes); // ensure List.from is generated | 18 new ListFactory.from(charCodes); // ensure List.from is generated |
| 17 } | 19 } |
| 18 | 20 |
| 19 static String join(List<String> strings, String separator) { | 21 static String join(List<String> strings, String separator) { |
| 20 if (strings.length == 0) return ''; | 22 if (strings.length == 0) return ''; |
| 21 String s = strings[0]; | 23 String s = strings[0]; |
| 22 for (int i = 1; i < strings.length; i++) { | 24 for (int i = 1; i < strings.length; i++) { |
| 23 s = s + separator + strings[i]; | 25 s = s + separator + strings[i]; |
| 24 } | 26 } |
| 25 return s; | 27 return s; |
| 26 } | 28 } |
| 27 | 29 |
| 28 static String concatAll(List<String> strings) => join(strings, ""); | 30 static String concatAll(List<String> strings) => join(strings, ""); |
| 29 } | 31 } |
| OLD | NEW |