Chromium Code Reviews| 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(); |
| } |