Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 62f04b831aeb91b86630e487cdaa4ae64d25b621..e9b325b4cde476c317e29457fbcbc2b2ae9ff8b8 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -473,12 +473,24 @@ STATIC_ASSERT((kExternalStringTag | kTwoByteStringTag) == |
STATIC_ASSERT(v8::String::TWO_BYTE_ENCODING == kTwoByteStringTag); |
+ |
uc32 FlatStringReader::Get(int index) { |
- DCHECK(0 <= index && index <= length_); |
if (is_one_byte_) { |
- return static_cast<const byte*>(start_)[index]; |
+ return Get<uint8_t>(index); |
+ } else { |
+ return Get<uc16>(index); |
+ } |
+} |
+ |
+ |
+template <typename Char> |
+Char FlatStringReader::Get(int index) { |
+ DCHECK_EQ(is_one_byte_, sizeof(Char) == 1); |
+ DCHECK(0 <= index && index <= length_); |
+ if (sizeof(Char) == 1) { |
+ return static_cast<Char>(static_cast<const uint8_t*>(start_)[index]); |
} else { |
- return static_cast<const uc16*>(start_)[index]; |
+ return static_cast<Char>(static_cast<const uc16*>(start_)[index]); |
} |
} |