зеркало из 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 const char *s = start;
|
||||||
register unsigned long retval = 0;
|
register unsigned long retval = 0;
|
||||||
const char *tmp;
|
signed char d;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (! s[0]) {
|
d = ruby_digit36_to_number_table[(unsigned char)*s];
|
||||||
break;
|
if (d < 0 || 15 < d) {
|
||||||
}
|
|
||||||
tmp = strchr(hexdigit, *s);
|
|
||||||
if (! tmp) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval <<= 4;
|
retval <<= 4;
|
||||||
retval |= (tmp - hexdigit) & 15;
|
retval |= d;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
*retlen = (int)(s - start); /* less than len */
|
*retlen = (int)(s - start); /* less than len */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче