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

Unified Diff: runtime/vm/unicode.h

Issue 11412258: Use the code point iterator when computing 16-bit string hash codes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: bugfix Created 8 years, 1 month 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/vm/object_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/unicode.h
diff --git a/runtime/vm/unicode.h b/runtime/vm/unicode.h
index 03a4b29d879898c2c83f06aac4a175d4729db209..9849951222edb2237df8c5ea7cc8d9ca4719e002 100644
--- a/runtime/vm/unicode.h
+++ b/runtime/vm/unicode.h
@@ -93,6 +93,21 @@ class Utf16 : AllStatic {
return (ch & 0xFFFFFC00) == 0xDC00;
}
+ // Returns the character at i and advances i to the next character
+ // boundary.
+ static int32_t Next(const uint16_t* characters, intptr_t* i, intptr_t len) {
+ int32_t ch = characters[*i];
+ if (Utf16::IsLeadSurrogate(ch) && (*i < (len - 1))) {
+ int32_t ch2 = characters[*i + 1];
+ if (Utf16::IsTrailSurrogate(ch2)) {
+ ch = Utf16::Decode(ch, ch2);
+ *i += 1;
+ }
+ }
+ *i += 1;
+ return ch;
+ }
+
// Decodes a surrogate pair into a supplementary code point.
static int32_t Decode(int32_t lead, int32_t trail) {
return 0x10000 + ((lead & 0x3FF) << 10) + (trail & 0x3FF);
« no previous file with comments | « runtime/vm/object_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698