Chromium Code Reviews| Index: runtime/lib/string_patch.dart |
| diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart |
| index 9d5111bd9ea391f0a5d643bbfcdd81440fb9057b..ead4b8f23321a5ec944a465cf0e408f57c595326 100644 |
| --- a/runtime/lib/string_patch.dart |
| +++ b/runtime/lib/string_patch.dart |
| @@ -34,6 +34,9 @@ class _StringBase { |
| */ |
| static String createFromCharCodes(Iterable<int> charCodes) { |
| if (charCodes != null) { |
| + if (charCodes is Uint8List || charCodes is Int8List) { |
|
Anders Johnsen
2013/11/18 20:26:31
Should we use _classId here as well?
srdjan
2013/11/18 20:45:15
Yes, using cid-s is much quicker.
Anders Johnsen
2013/11/19 07:38:43
I encountered an issue here. These classes are in
srdjan
2013/11/19 16:47:38
This would not slow down existing code:
if ((ccid
|
| + return _OneByteString._allocateFromOneByteList(charCodes); |
| + } |
| // TODO(srdjan): Also skip copying of typed arrays. |
| final ccid = charCodes._cid; |
| if ((ccid != _List._classId) && |
| @@ -53,11 +56,7 @@ class _StringBase { |
| } |
| } |
| if (isOneByteString) { |
| - var s = _OneByteString._allocate(charCodes.length); |
| - for (int i = 0; i < charCodes.length; i++) { |
| - s._setAt(i, charCodes[i]); |
| - } |
| - return s; |
| + return _OneByteString._allocateFromOneByteList(charCodes); |
|
srdjan
2013/11/18 20:45:15
Calling to native is quite slow, i.e., for small l
Anders Johnsen
2013/11/18 21:10:51
Before, we already did the runtime-call to allocat
|
| } |
| } |
| return _createFromCodePoints(charCodes); |
| @@ -628,6 +627,10 @@ class _OneByteString extends _StringBase implements String { |
| // set using _setAt. |
| static _OneByteString _allocate(int length) native "OneByteString_allocate"; |
| + |
| + static _OneByteString _allocateFromOneByteList(List<int> list) |
| + native "OneByteString_allocateFromOneByteList"; |
| + |
| // This is internal helper method. Code point value must be a valid |
| // Latin1 value (0..0xFF), index must be valid. |
| void _setAt(int index, int codePoint) native "OneByteString_setAt"; |