Bryan O'Sullivan avatar Bryan O'Sullivan committed b816391

encodeUtf8_2: drop parallel range checks

Once I noticed that I'd screwed up the range checking and fixed it,
it became slow enough to not be worth it. All test cases are about
10% faster with this extra complexity removed, with the exception
of pure Russian, which is about 50% slower.

Comments (0)

Files changed (1)

 #if defined(__x86_64__)
   while (srcend - src >= 4) {
     uint64_t w = *((uint64_t *) src);
-    uint16_t a = w & 0xFFFF, b = (w >> 16) & 0xFFFF, c = (w >> 32) & 0xFFFF,
-      d = w >> 48;
 
-    if ((w & 0xFF80FF80FF80FF80ULL) == 0) {
-      *dest++ = a;
-      *dest++ = b;
-      *dest++ = c;
-      *dest++ = d;
-    }
-    else if (!(w & 0xF800F800F800F800ULL) && (w & 0xFF80000000000000ULL) &&
-	     (w & 0x0000FF8000000000ULL) && (w & 0x00000000FF800000ULL) &&
-	     (w & 0x000000000000FF80ULL)) {
-      *dest++ = (a >> 6) | 0xC0;
-      *dest++ = (a & 0x3f) | 0x80;
-      *dest++ = (b >> 6) | 0xC0;
-      *dest++ = (b & 0x3f) | 0x80;
-      *dest++ = (c >> 6) | 0xC0;
-      *dest++ = (c & 0x3f) | 0x80;
-      *dest++ = (d >> 6) | 0xC0;
-      *dest++ = (d & 0x3f) | 0x80;
-    }
-    else break;
+    if (w & 0xFF80FF80FF80FF80ULL)
+      break;
+    *dest++ = w & 0xFFFF;
+    *dest++ = (w >> 16) & 0xFFFF;
+    *dest++ = (w >> 32) & 0xFFFF;
+    *dest++ = w >> 48;
     src += 4;
   }
 #endif
 #if defined(__i386__)
   while (srcend - src >= 2) {
     uint32_t w = *((uint32_t *) src);
-    uint16_t a = w & 0xFFFF, b = w >> 16;
 
-    if ((w & 0xFF80FF80) == 0) {
-      *dest++ = a;
-      *dest++ = b;
-    }
-    else if (!(w & 0xF800F800) && (w & 0xFF800000) && (w & 0x0000FF80)) {
-      *dest++ = (a >> 6) | 0xC0;
-      *dest++ = (a & 0x3f) | 0x80;
-      *dest++ = (b >> 6) | 0xC0;
-      *dest++ = (b & 0x3f) | 0x80;
-    }
-    else break;
+    if (w & 0xFF80FF80)
+      break;
+    *dest++ = w & 0xFFFF;
+    *dest++ = w >> 16;
     src += 2;
   }
 #endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.