1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Look up ruby_digit36_to_number_table

Instead of scanning ruby_hexdigits.
This commit is contained in:
Nobuyoshi Nakada 2021-07-20 19:54:59 +09:00
parent b2749e0026
commit 04b5e85bfd
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

11
util.c
View file

@ -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 */