Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: src/factory.cc

Issue 247093002: Do not avoid flattening cons string when creating a string slice. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698