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

Unified Diff: src/char-predicates-inl.h

Issue 42280: Made Date parser work on flat strings instead of arbitrary ones. (Closed)
Patch Set: Created 11 years, 9 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 | src/dateparser.h » ('j') | src/dateparser.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/char-predicates-inl.h
diff --git a/src/char-predicates-inl.h b/src/char-predicates-inl.h
index 3ef2f91616904f79b577c4c5eb1558b83aff63b3..217db9c33106248944d47bb9570f0f620134883e 100644
--- a/src/char-predicates-inl.h
+++ b/src/char-predicates-inl.h
@@ -43,26 +43,28 @@ inline bool IsLineFeed(uc32 c) {
}
+static inline bool IsInRange(int value, int lower_limit, int higher_limit) {
+ ASSERT(lower_limit <= higher_limit);
+ return static_cast<unsigned int>(value - lower_limit) <=
+ static_cast<unsigned int>(higher_limit - lower_limit);
+}
+
+
inline bool IsDecimalDigit(uc32 c) {
// ECMA-262, 3rd, 7.8.3 (p 16)
- return
- '0' <= c && c <= '9';
+ return IsInRange(c, '0', '9');
}
inline bool IsHexDigit(uc32 c) {
// ECMA-262, 3rd, 7.6 (p 15)
- return
- ('0' <= c && c <= '9') ||
- ('A' <= c && c <= 'F') ||
- ('a' <= c && c <= 'f');
+ return IsDecimalDigit(c) || IsInRange(c | 0x20, 'a', 'f');
}
inline bool IsRegExpWord(uc16 c) {
- return ('a' <= c && c <= 'z')
- || ('A' <= c && c <= 'Z')
- || ('0' <= c && c <= '9')
+ return IsInRange(c | 0x20, 'a', 'z')
+ || IsDecimalDigit(c)
|| (c == '_');
}
« no previous file with comments | « no previous file | src/dateparser.h » ('j') | src/dateparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698