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

ruby-changes:42783

From: naruse <ko1@a...>
Date: Sun, 1 May 2016 00:35:58 +0900 (JST)
Subject: [ruby-changes:42783] naruse:r54857 (trunk): More optimization for r54854's search_nonascii

naruse	2016-05-01 01:32:36 +0900 (Sun, 01 May 2016)

  New Revision: 54857

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54857

  Log:
    More optimization for r54854's search_nonascii

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 54856)
+++ string.c	(revision 54857)
@@ -455,19 +455,19 @@ search_nonascii(const char *p, const cha https://github.com/ruby/ruby/blob/trunk/string.c#L455
 	p = (const char *)s;
     }
 
-    switch ((e - p) % SIZEOF_VOIDP) {
+    switch (e - p) {
+      default: UNREACHABLE;
 #if SIZEOF_VOIDP > 4
-      case 7: if (*p&0x80) return p; p++;
-      case 6: if (*p&0x80) return p; p++;
-      case 5: if (*p&0x80) return p; p++;
-      case 4: if (*p&0x80) return p; p++;
+      case 7: if (e[-7]&0x80) return e-7;
+      case 6: if (e[-6]&0x80) return e-6;
+      case 5: if (e[-5]&0x80) return e-5;
+      case 4: if (e[-4]&0x80) return e-4;
 #endif
-      case 3: if (*p&0x80) return p; p++;
-      case 2: if (*p&0x80) return p; p++;
-      case 1: if (*p&0x80) return p;
+      case 3: if (e[-3]&0x80) return e-3;
+      case 2: if (e[-2]&0x80) return e-2;
+      case 1: if (e[-1]&0x80) return e-1;
+      case 0: return NULL;
     }
-
-    return NULL;
 }
 
 static int

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

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