Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 56b54323f0cf59711e6ee9047eb5524b29ca0020..03946ef559261efc7b495831575d6fcde5a0bad8 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -7413,32 +7413,42 @@ class String: public HeapObject { |
| int from, |
| int to); |
| - static inline bool IsAscii(const char* chars, int length) { |
| + static inline const char* NonAsciiStart(const char* chars, int length) { |
|
Yang
2012/10/18 14:46:23
Please add a comment on what the return value is (
Toon Verwaest
2012/10/18 15:06:56
Done.
|
| const char* limit = chars + length; |
| #ifdef V8_HOST_CAN_READ_UNALIGNED |
| ASSERT(kMaxAsciiCharCode == 0x7F); |
| const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80; |
| while (chars + sizeof(uintptr_t) <= limit) { |
| if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) { |
| - return false; |
| + return chars; |
| } |
| chars += sizeof(uintptr_t); |
| } |
| #endif |
| while (chars < limit) { |
| - if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return false; |
| + if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return chars; |
| ++chars; |
| } |
| - return true; |
| + return chars; |
| } |
| - static inline bool IsAscii(const uc16* chars, int length) { |
| + static inline bool IsAscii(const char* chars, int length) { |
| + const char* limit = chars + length; |
| + return NonAsciiStart(chars, length) >= limit; |
| + } |
| + |
| + static inline const uc16* NonAsciiStart(const uc16* chars, int length) { |
| const uc16* limit = chars + length; |
| while (chars < limit) { |
| - if (*chars > kMaxAsciiCharCodeU) return false; |
| + if (*chars > kMaxAsciiCharCodeU) return chars; |
| ++chars; |
| } |
| - return true; |
| + return chars; |
| + } |
| + |
| + static inline bool IsAscii(const uc16* chars, int length) { |
| + const uc16* limit = chars + length; |
| + return NonAsciiStart(chars, length) >= limit; |
| } |
| protected: |