Commit a5f71027 authored by karl's avatar karl Committed by Commit bot

Cache String.split not found results as well

Before String.split only cached results if the seperator was found

BUG=v8:4191
LOG=N

Review URL: https://codereview.chromium.org/1308373005

Cr-Commit-Position: refs/heads/master@{#30632}
parent b7db5cd9
......@@ -738,20 +738,20 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
DCHECK(result->HasFastObjectElements());
if (part_count == 1 && indices.at(0) == subject_length) {
FixedArray::cast(result->elements())->set(0, *subject);
return *result;
}
Handle<FixedArray> elements(FixedArray::cast(result->elements()));
int part_start = 0;
for (int i = 0; i < part_count; i++) {
HandleScope local_loop_handle(isolate);
int part_end = indices.at(i);
Handle<String> substring =
isolate->factory()->NewProperSubString(subject, part_start, part_end);
elements->set(i, *substring);
part_start = part_end + pattern_length;
if (part_count == 1 && indices.at(0) == subject_length) {
elements->set(0, *subject);
} else {
int part_start = 0;
for (int i = 0; i < part_count; i++) {
HandleScope local_loop_handle(isolate);
int part_end = indices.at(i);
Handle<String> substring =
isolate->factory()->NewProperSubString(subject, part_start, part_end);
elements->set(i, *substring);
part_start = part_end + pattern_length;
}
}
if (limit == 0xffffffffu) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment