Commits

Bryan O'Sullivan committed c1fab56

encodeUtf8: squeeze out a little more fast path performance

If we're about to drop from the fast to the slow path, try to cut
our losses by pushing out a few more bytes before we give up.

  • Participants
  • Parent commits 94da24e

Comments (0)

Files changed (1)

   while (srcend - src >= 4) {
     uint64_t w = *((uint64_t *) src);
 
-    if (w & 0xFF80FF80FF80FF80ULL)
+    if (w & 0xFF80FF80FF80FF80ULL) {
+      if (!(w & 0x000000000000FF80ULL)) {
+	*dest++ = w & 0xFFFF;
+	src++;
+	if (!(w & 0x00000000FF800000ULL)) {
+	  *dest++ = (w >> 16) & 0xFFFF;
+	  src++;
+	  if (!(w & 0x0000FF8000000000ULL)) {
+	    *dest++ = (w >> 32) & 0xFFFF;
+	    src++;
+	  }
+	}
+      }
       break;
+    }
     *dest++ = w & 0xFFFF;
     *dest++ = (w >> 16) & 0xFFFF;
     *dest++ = (w >> 32) & 0xFFFF;