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

Unified Diff: runtime/lib/string.cc

Issue 533483003: Cleanup throwing of the RangeError in the runtime to remove duplicated code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc
index 19222eb8c1d9db2bc6cc71d0c13fd35806462aa8..ce7731fde28884313fde54104e3508dfedca00fc 100644
--- a/runtime/lib/string.cc
+++ b/runtime/lib/string.cc
@@ -237,16 +237,12 @@ static int32_t StringValueAt(const String& str, const Integer& index) {
const Smi& smi = Smi::Cast(index);
intptr_t index = smi.Value();
if ((index < 0) || (index >= str.Length())) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, smi);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ Exceptions::ThrowRangeError(smi);
}
return str.CharAt(index);
} else {
// An index larger than Smi is always illegal.
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, index);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ Exceptions::ThrowRangeError(index);
return 0;
}
}
@@ -336,9 +332,7 @@ DEFINE_NATIVE_ENTRY(StringBuffer_createStringFromUint16Array, 3) {
intptr_t array_length = codeUnits.Length();
intptr_t length_value = length.Value();
if (length_value < 0 || length_value > array_length) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, length);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ Exceptions::ThrowRangeError(length);
}
const String& result = isLatin1.value()
? String::Handle(OneByteString::New(length_value, Heap::kNew))

Powered by Google App Engine
This is Rietveld 408576698