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

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') | runtime/vm/object.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
===================================================================
--- runtime/lib/string.cc (revision 15670)
+++ runtime/lib/string.cc (working copy)
@@ -74,26 +74,38 @@
}
+// This is high-performance code.
DEFINE_NATIVE_ENTRY(OneByteString_splitWithCharCode, 2) {
- const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
+ // 'isolate' is defined.
siva 2012/12/04 03:04:50 we have used isolate in the rest of the file with
srdjan 2012/12/04 21:41:30 Removed comment. I think it would be better if 'is
+ 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),
+ isolate,
siva 2012/12/04 03:04:50 If we have to pass isolate as a parameter I would
srdjan 2012/12/04 21:41:30 Done.
+ Heap::kNew);
+ result.Add(str, isolate);
siva 2012/12/04 03:04:50 Ditto comment.
srdjan 2012/12/04 21:41:30 Done.
start = i + 1;
}
}
- str = String::SubString(receiver, start, (i - start));
- result.Add(str);
+ str = OneByteString::SubStringUnchecked(receiver,
+ start,
+ (i - start),
+ isolate,
+ Heap::kNew);
+ result.Add(str, isolate);
return result.raw();
}
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698