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

Unified Diff: runtime/vm/object.cc

Issue 560113002: Narrow String::CharAt from int32_t to uint16_t. (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/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 99955ec64f587355a93ca5ef9ee016db777d1b32..e820e420d696c09dd36903667655eee994c2f585 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -17073,7 +17073,7 @@ intptr_t String::Hash(const int32_t* characters, intptr_t len) {
}
-int32_t String::CharAt(intptr_t index) const {
+uint16_t String::CharAt(intptr_t index) const {
intptr_t class_id = raw()->GetClassId();
ASSERT(RawObject::IsStringClassId(class_id));
NoGCScope no_gc;
@@ -17230,12 +17230,12 @@ intptr_t String::CompareTo(const String& other) const {
const intptr_t other_len = other.IsNull() ? 0 : other.Length();
const intptr_t len = (this_len < other_len) ? this_len : other_len;
for (intptr_t i = 0; i < len; i++) {
- int32_t this_code_point = this->CharAt(i);
- int32_t other_code_point = other.CharAt(i);
- if (this_code_point < other_code_point) {
+ uint16_t this_code_unit = this->CharAt(i);
+ uint16_t other_code_unit = other.CharAt(i);
+ if (this_code_unit < other_code_unit) {
return -1;
}
- if (this_code_point > other_code_point) {
+ if (this_code_unit > other_code_unit) {
return 1;
}
}
« runtime/lib/string.cc ('K') | « runtime/vm/object.h ('k') | runtime/vm/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698