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