[前][次][番号順一覧][スレッド一覧]

ruby-changes:66852

From: Nobuyoshi <ko1@a...>
Date: Wed, 21 Jul 2021 19:33:12 +0900 (JST)
Subject: [ruby-changes:66852] 04b5e85bfd (master): Look up ruby_digit36_to_number_table

https://git.ruby-lang.org/ruby.git/commit/?id=04b5e85bfd

From 04b5e85bfda5ba281f2129d148c952eabc5e49a3 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 20 Jul 2021 19:54:59 +0900
Subject: Look up ruby_digit36_to_number_table

Instead of scanning ruby_hexdigits.
---
 util.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/util.c b/util.c
index 21f5965..f4cea03 100644
--- a/util.c
+++ b/util.c
@@ -57,19 +57,16 @@ ruby_scan_hex(const char *start, size_t len, size_t *retlen) https://github.com/ruby/ruby/blob/trunk/util.c#L57
 {
     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 */
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]