зеркало из https://github.com/github/ruby.git
Look up ruby_digit36_to_number_table
Instead of scanning ruby_hexdigits.
This commit is contained in:
Родитель
b2749e0026
Коммит
04b5e85bfd
11
util.c
11
util.c
|
@ -57,19 +57,16 @@ ruby_scan_hex(const char *start, size_t len, size_t *retlen)
|
|||
{
|
||||
register const char *s = start;
|
||||
register unsigned long retval = 0;
|
||||
const char *tmp;
|
||||
signed char d;
|
||||
size_t i = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (! s[0]) {
|
||||
break;
|
||||
}
|
||||
tmp = strchr(hexdigit, *s);
|
||||
if (! tmp) {
|
||||
d = ruby_digit36_to_number_table[(unsigned char)*s];
|
||||
if (d < 0 || 15 < d) {
|
||||
break;
|
||||
}
|
||||
retval <<= 4;
|
||||
retval |= (tmp - hexdigit) & 15;
|
||||
retval |= d;
|
||||
s++;
|
||||
}
|
||||
*retlen = (int)(s - start); /* less than len */
|
||||
|
|
Загрузка…
Ссылка в новой задаче