Reviewers: Kasper Lund, Mads Ager,

Message:
I'm not sure, this is a toss up.  We can see what the bots say...

Description:
TryFlatten is inlined, while Flatten is not.  Make an optimization to
avoid the call to Flatten when we're already flat.  This gives me 5% on
some simple indexOf experiments.

Please review this at http://codereview.chromium.org/2986

Affected files:
   M src/objects-inl.h


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();
  }





--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to