Reviewers: sandholm,

Description:
Remove assertion that is no longer valid in InitializeStringSearch.

This assertion is no longer valid because r5380 changes the assumption
about the pat parameter.

In addition, we embed the no allocation part of StringSplit in a block
to reenable allocation later in that method.



Please review this at http://codereview.chromium.org/3254010/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/runtime.cc


Index: src/runtime.cc
===================================================================
--- src/runtime.cc      (revision 5380)
+++ src/runtime.cc      (working copy)
@@ -2913,7 +2913,6 @@
 template <typename pchar>
 static inline StringSearchStrategy InitializeStringSearch(
     Vector<const pchar> pat, bool ascii_subject) {
-  ASSERT(pat.length() > 1);
   // We have an ASCII haystack and a non-ASCII needle. Check if there
   // really is a non-ASCII character in the needle and bail out if there
   // is.
@@ -5237,40 +5236,45 @@
   int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
   ZoneList<int> indices(initial_capacity);
   if (!pattern->IsFlat()) FlattenString(pattern);
-  AssertNoAllocation nogc;
-  if (subject->IsAsciiRepresentation()) {
-    Vector<const char> subject_vector = subject->ToAsciiVector();
-    if (pattern->IsAsciiRepresentation()) {
-      FindStringIndices(subject_vector,
-                        pattern->ToAsciiVector(),
-                        &indices,
-                        limit);
+
+  // No allocation block.
+  {
+    AssertNoAllocation nogc;
+    if (subject->IsAsciiRepresentation()) {
+      Vector<const char> subject_vector = subject->ToAsciiVector();
+      if (pattern->IsAsciiRepresentation()) {
+        FindStringIndices(subject_vector,
+                          pattern->ToAsciiVector(),
+                          &indices,
+                          limit);
+      } else {
+        FindStringIndices(subject_vector,
+                          pattern->ToUC16Vector(),
+                          &indices,
+                          limit);
+      }
     } else {
-      FindStringIndices(subject_vector,
-                        pattern->ToUC16Vector(),
-                        &indices,
-                        limit);
+      Vector<const uc16> subject_vector = subject->ToUC16Vector();
+      if (pattern->IsAsciiRepresentation()) {
+        FindStringIndices(subject_vector,
+                          pattern->ToAsciiVector(),
+                          &indices,
+                          limit);
+      } else {
+        FindStringIndices(subject_vector,
+                          pattern->ToUC16Vector(),
+                          &indices,
+                          limit);
+      }
     }
-  } else {
-    Vector<const uc16> subject_vector = subject->ToUC16Vector();
-    if (pattern->IsAsciiRepresentation()) {
-      FindStringIndices(subject_vector,
-                        pattern->ToAsciiVector(),
-                        &indices,
-                        limit);
-    } else {
-      FindStringIndices(subject_vector,
-                        pattern->ToUC16Vector(),
-                        &indices,
-                        limit);
-    }
   }
+
   if (static_cast<uint32_t>(indices.length()) < limit) {
     indices.Add(subject_length);
   }
+
   // The list indices now contains the end of each part to create.

-
   // Create JSArray of substrings separated by separator.
   int part_count = indices.length();



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to