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

Unified Diff: runtime/lib/typed_data.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
« no previous file with comments | « runtime/lib/string.cc ('k') | runtime/vm/exceptions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/typed_data.cc
diff --git a/runtime/lib/typed_data.cc b/runtime/lib/typed_data.cc
index 2ff65d7c2a0c42e0ac7d21ca58320ef0e00952a8..8724dbcd65b4590171c6ffabb37245e8e315b150 100644
--- a/runtime/lib/typed_data.cc
+++ b/runtime/lib/typed_data.cc
@@ -21,13 +21,12 @@ static void RangeCheck(intptr_t offset_in_bytes,
intptr_t length_in_bytes,
intptr_t element_size_in_bytes) {
if (!Utils::RangeCheck(offset_in_bytes, access_size, length_in_bytes)) {
- const String& error = String::Handle(String::NewFormatted(
- "index (%" Pd ") must be in the range [0..%" Pd ")",
- (offset_in_bytes + access_size) / element_size_in_bytes,
- (length_in_bytes / element_size_in_bytes)));
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, error);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ const intptr_t index =
+ (offset_in_bytes + access_size) / element_size_in_bytes;
+ const intptr_t length =
+ length_in_bytes / element_size_in_bytes;
+ Exceptions::ThrowRangeError(
+ "index", Integer::Handle(Integer::New(index)), 0, length);
}
}
« no previous file with comments | « runtime/lib/string.cc ('k') | runtime/vm/exceptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698