Commit ab377a3f authored by deanm@chromium.org's avatar deanm@chromium.org

TryFlatten is inlined, while Flatten is not. Make an optimization to avoid...

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.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@347 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cc8fd0e5
......@@ -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();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment