Revision: 20882
Author:   [email protected]
Date:     Tue Apr 22 11:19:27 2014 UTC
Log:      Do not avoid flattening cons string when creating a string slice.

[email protected]
BUG=364656
LOG=N

Review URL: https://codereview.chromium.org/247093002
http://code.google.com/p/v8/source/detail?r=20882

Modified:
 /branches/bleeding_edge/src/factory.cc

=======================================
--- /branches/bleeding_edge/src/factory.cc      Tue Apr 22 08:30:09 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc      Tue Apr 22 11:19:27 2014 UTC
@@ -532,6 +532,8 @@
 #endif
   ASSERT(begin > 0 || end < str->length());

+  str = String::Flatten(str);
+
   int length = end - begin;
   if (length <= 0) return empty_string();
   if (length == 1) {
@@ -566,28 +568,10 @@

   int offset = begin;

-  while (str->IsConsString()) {
-    Handle<ConsString> cons = Handle<ConsString>::cast(str);
-    int split = cons->first()->length();
-    if (split <= offset) {
-      // Slice is fully contained in the second part.
-      str = Handle<String>(cons->second(), isolate());
-      offset -= split;  // Adjust for offset.
-      continue;
-    } else if (offset + length <= split) {
-      // Slice is fully contained in the first part.
-      str = Handle<String>(cons->first(), isolate());
-      continue;
-    }
-    break;
-  }
-
   if (str->IsSlicedString()) {
     Handle<SlicedString> slice = Handle<SlicedString>::cast(str);
     str = Handle<String>(slice->parent(), isolate());
     offset += slice->offset();
-  } else {
-    str = String::Flatten(str);
   }

   ASSERT(str->IsSeqString() || str->IsExternalString());

--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to