Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: runtime/lib/string.cc

Issue 169893003: Another round of cleanups for http://www.dartbug.com/15922 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/lib/string.cc
===================================================================
--- runtime/lib/string.cc (revision 32732)
+++ runtime/lib/string.cc (working copy)
@@ -73,15 +73,17 @@
intptr_t value = Smi::Cast(index_object).Value();
if (Utf::IsOutOfRange(value)) {
Exceptions::ThrowByType(Exceptions::kArgument, Object::empty_array());
- } else {
- if (!Utf::IsLatin1(value)) {
- is_one_byte_string = false;
- if (Utf::IsSupplementary(value)) {
- utf16_len += 1;
- }
+ UNREACHABLE();
+ }
+ // Now it is safe to cast the value.
+ int32_t value32 = static_cast<int32_t>(value);
+ if (!Utf::IsLatin1(value32)) {
+ is_one_byte_string = false;
+ if (Utf::IsSupplementary(value32)) {
+ utf16_len += 1;
}
}
- utf32_array[i] = value;
+ utf32_array[i] = value32;
}
if (is_one_byte_string) {
return OneByteString::New(utf32_array, array_len, Heap::kNew);
@@ -237,7 +239,7 @@
static int32_t StringValueAt(const String& str, const Integer& index) {
if (index.IsSmi()) {
const Smi& smi = Smi::Cast(index);
- int32_t index = smi.Value();
+ intptr_t index = smi.Value();
if ((index < 0) || (index >= str.Length())) {
const Array& args = Array::Handle(Array::New(1));
args.SetAt(0, smi);

Powered by Google App Engine
This is Rietveld 408576698