Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 7d46c068589bfb707a43e93d84bf5cc74e328275..5f04fe1e61d929ba47e86c45e3e804ac5644da0d 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -7189,6 +7189,13 @@ class String: public HeapObject { |
| ASSERT_EQ(TWO_BYTE, state_); |
| return Vector<const uc16>::cast(buffer_); |
| } |
| + // Return the character length of the string. |
| + unsigned Length() const { |
| + if (state_ == ASCII) return buffer_.length(); |
| + if (state_ == TWO_BYTE) return buffer_.length() / 2; |
|
Yang
2012/11/26 08:45:30
you could do an
if (state_ == ASCII) {
...
} els
|
| + UNREACHABLE(); |
| + return 0; // Placate compiler. |
| + } |
| private: |
| enum State { NON_FLAT, ASCII, TWO_BYTE }; |