TryFlatten is inlined, while Flatten is not. Make an optimization to avoid the call...
authordeanm@chromium.org <deanm@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 19 Sep 2008 11:06:35 +0000 (11:06 +0000)
committerdeanm@chromium.org <deanm@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 19 Sep 2008 11:06:35 +0000 (11:06 +0000)
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@347 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/objects-inl.h

index 271dd7e..6c1296a 100644 (file)
@@ -1198,7 +1198,12 @@ 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();
+  }
 }