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

Unified Diff: src/runtime.cc

Issue 6991007: Don't flatten every time we call CharCodeAt Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Handle flat cons string. Flatten entire string. Created 9 years, 7 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
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index b32ae8a1b4b81a85c4d8e0d1737eea1b367d61b3..c12c71d8ec112c5ae81edb1d909967f0a1616b1b 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -2060,20 +2060,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) {
i = static_cast<uint32_t>(DoubleToInteger(value));
}
- // Flatten the string. If someone wants to get a char at an index
- // in a cons string, it is likely that more indices will be
- // accessed.
- Object* flat;
- { MaybeObject* maybe_flat = subject->TryFlatten();
- if (!maybe_flat->ToObject(&flat)) return maybe_flat;
- }
- subject = String::cast(flat);
-
if (i >= static_cast<uint32_t>(subject->length())) {
return isolate->heap()->nan_value();
}
- return Smi::FromInt(subject->Get(i));
+ return subject->GetMayFlatten(i);
}
@@ -3636,9 +3627,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) {
// string->Get(index).
static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
if (index < static_cast<uint32_t>(string->length())) {
- string->TryFlatten();
return LookupSingleCharacterStringFromCode(
- string->Get(index));
+ StringGetMayFlatten(string, index));
}
return Execution::CharAt(string, index);
}
« src/objects-inl.h ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698