Chromium Code Reviews| Index: runtime/lib/string.cc |
| diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc |
| index 2573b9ae0042e494926498af1793436151534223..58b9e4c57c076401e73211f3c2214664e1433fb4 100644 |
| --- a/runtime/lib/string.cc |
| +++ b/runtime/lib/string.cc |
| @@ -218,7 +218,7 @@ DEFINE_NATIVE_ENTRY(String_getLength, 1) { |
| } |
| -static int32_t StringValueAt(const String& str, const Integer& index) { |
| +static uint16_t StringValueAt(const String& str, const Integer& index) { |
| if (index.IsSmi()) { |
| const intptr_t index_value = Smi::Cast(index).Value(); |
| if ((0 <= index_value) && (index_value < str.Length())) { |
| @@ -235,9 +235,8 @@ static int32_t StringValueAt(const String& str, const Integer& index) { |
| DEFINE_NATIVE_ENTRY(String_charAt, 2) { |
| const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); |
| - uint32_t value = StringValueAt(receiver, index); |
| - ASSERT(value <= 0x10FFFF); |
| - return Symbols::FromCharCode(value); |
| + uint16_t value = StringValueAt(receiver, index); |
| + return Symbols::FromCharCode(static_cast<int32_t>(value)); |
| } |
| @@ -245,10 +244,8 @@ DEFINE_NATIVE_ENTRY(String_codeUnitAt, 2) { |
| const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); |
|
siva
2014/09/11 20:22:59
Can you add a comment that this function returns a
|
| - int32_t value = StringValueAt(receiver, index); |
| - ASSERT(value >= 0); |
| - ASSERT(value <= 0xFFFF); |
| - return Smi::New(value); |
| + uint16_t value = StringValueAt(receiver, index); |
| + return Smi::New(static_cast<intptr_t>(value)); |
| } |