Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1810)

Unified Diff: runtime/lib/string_patch.dart

Issue 25087006: Improve performance of string buffer by modifying concatAll native to allow growable array and an i… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/string_buffer_patch.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string_patch.dart
===================================================================
--- runtime/lib/string_patch.dart (revision 28096)
+++ runtime/lib/string_patch.dart (working copy)
@@ -395,9 +395,9 @@
* Convert all objects in [values] to strings and concat them
* into a result string.
*/
- static String _interpolate(List values) {
+ static String _interpolate(List<String> values) {
final int numValues = values.length;
- _ObjectArray stringList = new List(numValues);
+ _ObjectArray stringList = new List<String>(numValues);
bool isOneByteString = true;
int totalLength = 0;
for (int i = 0; i < numValues; i++) {
@@ -412,7 +412,7 @@
if (isOneByteString) {
return _OneByteString._concatAll(stringList, totalLength);
}
- return _concatAllNative(stringList);
+ return _concatAllNative(stringList, 0, stringList.length);
}
Iterable<Match> allMatches(String str) {
@@ -497,8 +497,9 @@
String toLowerCase() native "String_toLowerCase";
- // Call this method if not all list elements are OneByteString-s.
- static String _concatAllNative(_ObjectArray<String> strings)
+ // Call this method if not all list elements are known to be OneByteString(s).
+ // 'strings' must be an _ObjectArray or _GrowableObjectArray.
+ static String _concatAllNative(List<String> strings, int start, int end)
native "Strings_concatAll";
}
@@ -535,7 +536,7 @@
// TODO(srdjan): Improve code below and raise or eliminate the limit.
if (totalLength > 128) {
// Native is quicker.
- return _StringBase._concatAllNative(strings);
+ return _StringBase._concatAllNative(strings, 0, strings.length);
}
var res = _OneByteString._allocate(totalLength);
final stringsLength = strings.length;
« no previous file with comments | « runtime/lib/string_buffer_patch.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698