Modified: trunk/Source/_javascript_Core/ChangeLog (182369 => 182370)
--- trunk/Source/_javascript_Core/ChangeLog 2015-04-06 00:23:46 UTC (rev 182369)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-04-06 01:32:12 UTC (rev 182370)
@@ -1,3 +1,20 @@
+2015-04-05 Andreas Kling <akl...@apple.com>
+
+ URI encoding/escaping should use efficient string building instead of calling snprintf().
+ <https://webkit.org/b/143426>
+
+ Reviewed by Gavin Barraclough.
+
+ I saw 0.5% of main thread time in snprintf() on <http://polymerlabs.github.io/benchmarks/>
+ which seemed pretty silly. This change gets that down to nothing in favor of using our
+ existing JSStringBuilder and HexNumber.h facilities.
+
+ These APIs are well-exercised by our existing test suite.
+
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::encode):
+ (JSC::globalFuncEscape):
+
2015-04-05 Masataka Yakura <masataka.yak...@gmail.com>
documentation for ES Promises points to the wrong one
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (182369 => 182370)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2015-04-06 00:23:46 UTC (rev 182369)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2015-04-06 01:32:12 UTC (rev 182370)
@@ -42,6 +42,7 @@
#include <stdlib.h>
#include <wtf/ASCIICType.h>
#include <wtf/Assertions.h>
+#include <wtf/HexNumber.h>
#include <wtf/MathExtras.h>
#include <wtf/StringExtras.h>
#include <wtf/text/StringBuilder.h>
@@ -65,9 +66,8 @@
if (c && strchr(doNotEscape, c))
builder.append(static_cast<LChar>(c));
else {
- char tmp[4];
- snprintf(tmp, sizeof(tmp), "%%%02X", static_cast<unsigned char>(c));
- builder.append(tmp);
+ builder.append(static_cast<LChar>('%'));
+ appendByteAsHex(c, builder);
}
}
return builder.build(exec);
@@ -676,9 +676,8 @@
if (u && strchr(do_not_escape, static_cast<char>(u)))
builder.append(*c);
else {
- char tmp[4];
- snprintf(tmp, sizeof(tmp), "%%%02X", u);
- builder.append(tmp);
+ builder.append(static_cast<LChar>('%'));
+ appendByteAsHex(static_cast<LChar>(u), builder);
}
}
@@ -689,15 +688,15 @@
for (unsigned k = 0; k < str.length(); k++, c++) {
int u = c[0];
if (u > 255) {
- char tmp[7];
- snprintf(tmp, sizeof(tmp), "%%u%04X", u);
- builder.append(tmp);
+ builder.append(static_cast<LChar>('%'));
+ builder.append(static_cast<LChar>('u'));
+ appendByteAsHex(u >> 8, builder);
+ appendByteAsHex(u & 0xFF, builder);
} else if (u != 0 && strchr(do_not_escape, static_cast<char>(u)))
builder.append(*c);
else {
- char tmp[4];
- snprintf(tmp, sizeof(tmp), "%%%02X", u);
- builder.append(tmp);
+ builder.append(static_cast<LChar>('%'));
+ appendByteAsHex(u, builder);
}
}