mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
querystring: improve escape() performance
This commit improves escape() performance by up to 15% with the existing querystring-stringify benchmarks by reducing the number of string concatentations. A potential deopt is also avoided by making sure the index passed to charCodeAt() is within bounds. PR-URL: https://github.com/nodejs/node/pull/5012 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
27e323e8c1
commit
46be1f4d0c
2 files changed
+24
-11
No files matched your search
@@ -4,7 +4,7 @@ var v8 = require('v8');
|
||||
|
||||
var bench = common.createBenchmark(main, {
|
||||
type: ['noencode', 'encodemany', 'encodelast'],
|
||||
n: [1e6],
|
||||
n: [1e7],
|
||||
});
|
||||
|
||||
function main(conf) {
|
||||
@@ -37,6 +37,7 @@ function main(conf) {
|
||||
|
||||
v8.setFlagsFromString('--allow_natives_syntax');
|
||||
eval('%OptimizeFunctionOnNextCall(querystring.stringify)');
|
||||
querystring.stringify(input);
|
||||
|
||||
bench.start();
|
||||
for (var i = 0; i < n; i += 1)
|
||||
|
||||
Reference in new issue
Block a user