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

Side by Side Diff: src/char-predicates-inl.h

Issue 969353003: Speed up identifier, keyword and smi parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use char predicates Created 5 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 unified diff | Download patch
« no previous file with comments | « src/char-predicates.h ('k') | src/scanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_CHAR_PREDICATES_INL_H_ 5 #ifndef V8_CHAR_PREDICATES_INL_H_
6 #define V8_CHAR_PREDICATES_INL_H_ 6 #define V8_CHAR_PREDICATES_INL_H_
7 7
8 #include "src/char-predicates.h" 8 #include "src/char-predicates.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 17 matching lines...) Expand all
28 return c == 0x000A; 28 return c == 0x000A;
29 } 29 }
30 30
31 31
32 inline bool IsInRange(int value, int lower_limit, int higher_limit) { 32 inline bool IsInRange(int value, int lower_limit, int higher_limit) {
33 DCHECK(lower_limit <= higher_limit); 33 DCHECK(lower_limit <= higher_limit);
34 return static_cast<unsigned int>(value - lower_limit) <= 34 return static_cast<unsigned int>(value - lower_limit) <=
35 static_cast<unsigned int>(higher_limit - lower_limit); 35 static_cast<unsigned int>(higher_limit - lower_limit);
36 } 36 }
37 37
38 inline bool IsAsciiIdentifier(uc32 c) {
39 return IsAlphaNumeric(c) || c == '$' || c == '_';
40 }
41
42 inline bool IsAlphaNumeric(uc32 c) {
43 return IsInRange(AsciiAlphaToLower(c), 'a', 'z') || IsDecimalDigit(c);
44 }
38 45
39 inline bool IsDecimalDigit(uc32 c) { 46 inline bool IsDecimalDigit(uc32 c) {
40 // ECMA-262, 3rd, 7.8.3 (p 16) 47 // ECMA-262, 3rd, 7.8.3 (p 16)
41 return IsInRange(c, '0', '9'); 48 return IsInRange(c, '0', '9');
42 } 49 }
43 50
44 51
45 inline bool IsHexDigit(uc32 c) { 52 inline bool IsHexDigit(uc32 c) {
46 // ECMA-262, 3rd, 7.6 (p 15) 53 // ECMA-262, 3rd, 7.6 (p 15)
47 return IsDecimalDigit(c) || IsInRange(AsciiAlphaToLower(c), 'a', 'f'); 54 return IsDecimalDigit(c) || IsInRange(AsciiAlphaToLower(c), 'a', 'f');
(...skipping 26 matching lines...) Expand all
74 return false; 81 return false;
75 default: 82 default:
76 return true; 83 return true;
77 } 84 }
78 } 85 }
79 86
80 87
81 } } // namespace v8::internal 88 } } // namespace v8::internal
82 89
83 #endif // V8_CHAR_PREDICATES_INL_H_ 90 #endif // V8_CHAR_PREDICATES_INL_H_
OLDNEW
« no previous file with comments | « src/char-predicates.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698