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

Unified Diff: src/objects.cc

Issue 6991007: Don't flatten every time we call CharCodeAt Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 519909c914185aa899860cb77ee185304db815d9..177febb00a0d8ebef88eb199f0b7f39bbb1a01e1 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5181,7 +5181,7 @@ uint16_t ConsString::ConsStringGet(int index) {
// Check for a flattened cons string
if (second()->length() == 0) {
String* left = first();
- return left->Get(index);
+ return FlatString::cast(left)->FlatStringGet(index);
}
String* string = String::cast(this);
@@ -5197,7 +5197,7 @@ uint16_t ConsString::ConsStringGet(int index) {
string = cons_string->second();
}
} else {
- return string->Get(index);
+ return FlatString::cast(string)->FlatStringGet(index);
}
}
@@ -5206,6 +5206,20 @@ uint16_t ConsString::ConsStringGet(int index) {
}
+MaybeObject* ConsString::ConsStringGetMayFlatten(int index) {
+ ASSERT(index >= 0);
+ ASSERT(index < this->length());
+
+ String* string = this;
+ if (this->GetIsolate()->ShouldFlattenString()) {
Vitaly Repeshko 2011/05/10 13:07:02 Here "this" can already be a flat cons (i.e. with
Lasse Reichstein 2011/05/10 16:27:46 Good point. We should probably not get here for a
+ MaybeObject* flatten_result = this->TryFlatten();
+ if (flatten_result->IsFailure()) return flatten_result;
+ string = String::cast(flatten_result->ToObjectUnchecked());
+ }
+ return Smi::FromInt(string->Get(index));
+}
+
+
template <typename sinkchar>
void String::WriteToFlat(String* src,
sinkchar* sink,
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698