Reviewers: ulan,
Description:
Do not avoid flattening cons string when creating a string slice.
[email protected]
BUG=364656
LOG=N
Please review this at https://codereview.chromium.org/247093002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+2, -18 lines):
M src/factory.cc
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index
2dcbfecd7fc76d83139ad42cecff4db7b7b10f58..42a60094efc7b20da31235874875bd6365f886f7
100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -532,6 +532,8 @@ Handle<String>
Factory::NewProperSubString(Handle<String> str,
#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 @@ Handle<String>
Factory::NewProperSubString(Handle<String> str,
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.