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:
parent
b2749e0026
commit
04b5e85bfd
1 changed files with 4 additions and 7 deletions
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 */
|
||||
|
|
Loading…
Reference in a new issue