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

Unified Diff: src/unicode.cc

Issue 155414: Small cleanup to Utf8::CalculateValue: (Closed)
Patch Set: Created 11 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/unicode.cc
diff --git a/src/unicode.cc b/src/unicode.cc
index 4a9e070ac5143732157641fbacf918d016ec999f..ef1359321f4e98eeb733fdfbfa8e336aebaf4b28 100644
--- a/src/unicode.cc
+++ b/src/unicode.cc
@@ -194,18 +194,13 @@ static int LookupMapping(const int32_t* table,
uchar Utf8::CalculateValue(const byte* str,
unsigned length,
unsigned* cursor) {
- static const uchar kMaxOneByteChar = 0x7F;
- static const uchar kMaxTwoByteChar = 0x7FF;
- static const uchar kMaxThreeByteChar = 0xFFFF;
- static const uchar kMaxFourByteChar = 0x1FFFFF;
-
// We only get called for non-ascii characters.
if (length == 1) {
*cursor += 1;
return kBadChar;
}
- int first = str[0];
- int second = str[1] ^ 0x80;
+ byte first = str[0];
+ byte second = str[1] ^ 0x80;
if (second & 0xC0) {
*cursor += 1;
return kBadChar;
@@ -227,7 +222,7 @@ uchar Utf8::CalculateValue(const byte* str,
*cursor += 1;
return kBadChar;
}
- int third = str[2] ^ 0x80;
+ byte third = str[2] ^ 0x80;
if (third & 0xC0) {
*cursor += 1;
return kBadChar;
@@ -245,7 +240,7 @@ uchar Utf8::CalculateValue(const byte* str,
*cursor += 1;
return kBadChar;
}
- int fourth = str[3] ^ 0x80;
+ byte fourth = str[3] ^ 0x80;
if (fourth & 0xC0) {
*cursor += 1;
return kBadChar;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698