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

Unified Diff: src/objects-inl.h

Issue 2986: TryFlatten is inlined, while Flatten is not. Make an optimization to avoid t... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Comments and check for external strings. Created 12 years, 3 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/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 271dd7ebf9432da075cf63dc716172efc1c29197..8fec4d1630e6a7c478eff0ebb3956805fb51ca7f 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1198,7 +1198,11 @@ void String::set_length_field(int value) {
void String::TryFlatten() {
- Flatten();
+ // We don't need to flatten strings that are already flat. Since this code
+ // is inlined, it can be helpful in the flat case to not call out to Flatten.
+ StringRepresentationTag str_type = representation_tag();
+ if (str_type != kSeqStringTag && str_type != kExternalStringTag)
+ Flatten();
}
« 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