Reviewers: Jakob,

Message:
Sorry didn't really know who to pick because yangguo is apparently OOO so I
picked you again

Description:
Cache String.split not found results as well

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

BUG=v8:4191

Please review this at https://codereview.chromium.org/1308373005/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+13, -13 lines):
  M src/runtime/runtime-regexp.cc


Index: src/runtime/runtime-regexp.cc
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
index 406c98fc60d95e7ed47f736ac82186e952d05a5e..acefe0767b3cb1de46eb3882be9f808993817d22 100644
--- a/src/runtime/runtime-regexp.cc
+++ b/src/runtime/runtime-regexp.cc
@@ -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) {


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to