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

Unified Diff: runtime/lib/string.cc

Issue 11308337: Improve C++ code for string splittig (Dromaeo benchmark). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
===================================================================
--- runtime/lib/string.cc (revision 15701)
+++ runtime/lib/string.cc (working copy)
@@ -74,26 +74,35 @@
}
+// This is high-performance code.
DEFINE_NATIVE_ENTRY(OneByteString_splitWithCharCode, 2) {
- const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
+ const String& receiver = String::CheckedHandle(isolate,
+ arguments->NativeArgAt(0));
ASSERT(receiver.IsOneByteString());
GET_NATIVE_ARGUMENT(Smi, smi_split_code, arguments->NativeArgAt(1));
const intptr_t len = receiver.Length();
const intptr_t split_code = smi_split_code.Value();
const GrowableObjectArray& result = GrowableObjectArray::Handle(
- GrowableObjectArray::New(4, Heap::kNew));
- String& str = String::Handle();
+ isolate,
+ GrowableObjectArray::New(16, Heap::kNew));
+ String& str = String::Handle(isolate);
intptr_t start = 0;
intptr_t i = 0;
for (; i < len; i++) {
- if (split_code == receiver.CharAt(i)) {
- str = String::SubString(receiver, start, (i - start));
- result.Add(str);
+ if (split_code == OneByteString::CharAt(receiver, i)) {
+ str = OneByteString::SubStringUnchecked(receiver,
+ start,
+ (i - start),
+ Heap::kNew);
+ result.Add(isolate, str);
start = i + 1;
}
}
- str = String::SubString(receiver, start, (i - start));
- result.Add(str);
+ str = OneByteString::SubStringUnchecked(receiver,
+ start,
+ (i - start),
+ Heap::kNew);
+ result.Add(isolate, str);
return result.raw();
}
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698