2002-11-24 Miguel de Icaza <miguel@ximian.com>
- * cs-tokenizer.cs (consume_identifier): Cut by half the number of
+ * cs-tokenizer.cs: Avoid calling Char.IsDigit which is an
+ internalcall as it is a pretty simple operation; Avoid whenever
+ possible to call Char.IsLetter.
+
+ (consume_identifier): Cut by half the number of
hashtable calls by merging the is_keyword and GetKeyword behavior.
Do not short-circuit, because if we do, we
\r
bool is_identifier_start_character (char c)\r
{\r
- return Char.IsLetter (c) || c == '_' ;\r
+ return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || Char.IsLetter (c);\r
}\r
\r
bool is_identifier_part_character (char c)\r
{\r
- return (Char.IsLetter (c) || Char.IsDigit (c) || c == '_');\r
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);\r
}\r
\r
int is_punct (char c, ref bool doread)\r
number_builder.Append ((char) c);\r
\r
while ((d = peekChar ()) != -1){\r
- if (Char.IsDigit ((char)d)){\r
+ if (d >= '0' && d <= '9'){\r
number_builder.Append ((char) d);\r
getChar ();\r
seen_digits = true;\r
return seen_digits;\r
}\r
\r
- bool is_hex (char e)\r
+ bool is_hex (int e)\r
{\r
- return Char.IsDigit (e) || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');\r
+ return (e >= '0' && e <= '9') || (e >= 'A' && e <= 'F') || (e >= 'a' && e <= 'f');\r
}\r
\r
void hex_digits (int c)\r
if (c != -1)\r
number_builder.Append ((char) c);\r
while ((d = peekChar ()) != -1){\r
- char e = Char.ToUpper ((char) d);\r
- \r
- if (is_hex (e)){\r
- number_builder.Append ((char) e);\r
+ if (is_hex (d)){\r
+ number_builder.Append ((char) d);\r
getChar ();\r
} else\r
break;\r
\r
number_builder.Length = 0;\r
\r
- if (Char.IsDigit ((char)c)){\r
+ if (c >= '0' && c <= '9'){\r
if (c == '0' && peekChar () == 'x' || peekChar () == 'X'){\r
ulong ul;\r
getChar ();\r
error = false;\r
for (i = 0; i < top; i++){\r
c = getChar ();\r
- e = Char.ToUpper ((char) c);\r
\r
- if (!is_hex (e)){\r
+ if (c >= '0' && c <= '9')\r
+ c = (int) c - (int) '0';\r
+ else if (c >= 'A' && c <= 'F')\r
+ c = (int) c - (int) 'A' + 10;\r
+ else if (c >= 'a' && c <= 'f')\r
+ c = (int) c - (int) 'a' + 10;\r
+ else {\r
error = true;\r
return 0;\r
}\r
- if (Char.IsDigit (e))\r
- c = (int) e - (int) '0';\r
- else\r
- c = (int) e - (int) 'A' + 10;\r
+ \r
total = (total * 16) + c;\r
if (count == -1){\r
int p = peekChar ();\r
\r
if (c == '.'){\r
tokens_seen = true;\r
- if (Char.IsDigit ((char) peekChar ()))\r
+ int peek = peekChar ();\r
+ if (peek >= '0' && peek <= '9')\r
return is_number (c);\r
return Token.DOT;\r
}\r
\r
- if (Char.IsDigit ((char) c)){\r
+ if (c >= '0' && c <= '9'){\r
tokens_seen = true;\r
return is_number (c);\r
}\r