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
This commit is contained in:
deanm@chromium.org 2008-09-19 11:06:35 +00:00
parent cc8fd0e527
commit ab377a3f42

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