From ab377a3f4216fdd809c769b8d4f1bcbc0c028084 Mon Sep 17 00:00:00 2001 From: "deanm@chromium.org" Date: Fri, 19 Sep 2008 11:06:35 +0000 Subject: [PATCH] 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 --- src/objects-inl.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/objects-inl.h b/src/objects-inl.h index 271dd7e..6c1296a 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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(); + } } -- 2.7.4