[JSC] Speed up URL encode/decode by using bitmaps instead of strchr().
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2015 04:49:36 +0000 (04:49 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 May 2015 04:49:36 +0000 (04:49 +0000)
<https://webkit.org/b/145115>

Incorporate review feedback from Darin, removing some unnecessary zero checks.

Patch by Yusuke Suzuki <utatane.tea@gmail.com> on 2015-05-19

* runtime/JSGlobalObjectFunctions.cpp:
(JSC::encode):
(JSC::decode):
(JSC::globalFuncEscape):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184613 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

index df582dd..7164abb 100644 (file)
@@ -1,5 +1,17 @@
 2015-05-19  Yusuke Suzuki  <utatane.tea@gmail.com>
 
+        [JSC] Speed up URL encode/decode by using bitmaps instead of strchr().
+        <https://webkit.org/b/145115>
+
+        Incorporate review feedback from Darin, removing some unnecessary zero checks.
+
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::encode):
+        (JSC::decode):
+        (JSC::globalFuncEscape):
+
+2015-05-19  Andreas Kling  <akling@apple.com>
+
         Move AtomicStringImpl table related operations from AtomicString to AtomicStringImpl
         https://bugs.webkit.org/show_bug.cgi?id=145109
 
index d42804d..11e009f 100644 (file)
@@ -72,7 +72,7 @@ static JSValue encode(ExecState* exec, const Bitmap<256>& doNotEscape)
     const char* p = cstr.data();
     for (size_t k = 0; k < cstr.length(); k++, p++) {
         char c = *p;
-        if (c && doNotEscape.get(static_cast<LChar>(c)))
+        if (doNotEscape.get(static_cast<LChar>(c)))
             builder.append(static_cast<LChar>(c));
         else {
             builder.append(static_cast<LChar>('%'));
@@ -136,7 +136,7 @@ static JSValue decode(ExecState* exec, const CharType* characters, int length, c
                     u = Lexer<UChar>::convertUnicode(p[2], p[3], p[4], p[5]);
                 }
             }
-            if (charLen && (u == 0 || u >= 128 || !doNotUnescape.get(static_cast<LChar>(u)))) {
+            if (charLen && (u >= 128 || !doNotUnescape.get(static_cast<LChar>(u)))) {
                 builder.append(u);
                 k += charLen;
                 continue;
@@ -687,7 +687,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
         const LChar* c = str.characters8();
         for (unsigned k = 0; k < str.length(); k++, c++) {
             int u = c[0];
-            if (u && doNotEscape.get(static_cast<LChar>(u)))
+            if (doNotEscape.get(static_cast<LChar>(u)))
                 builder.append(*c);
             else {
                 builder.append(static_cast<LChar>('%'));
@@ -706,7 +706,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec)
             builder.append(static_cast<LChar>('u'));
             appendByteAsHex(u >> 8, builder);
             appendByteAsHex(u & 0xFF, builder);
-        } else if (u != 0 && doNotEscape.get(static_cast<LChar>(u)))
+        } else if (doNotEscape.get(static_cast<LChar>(u)))
             builder.append(*c);
         else {
             builder.append(static_cast<LChar>('%'));