diff options
author | Brian White <mscdex@mscdex.net> | 2016-01-31 13:54:18 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2016-02-12 19:59:49 -0500 |
commit | a2a69a2b632e5c186f6af1bca79c349fa25580df (patch) | |
tree | 8c7ee17bd86f3a6dfb5e4a543d5afe4c78958bba /test/parallel/test-querystring.js | |
parent | 90451a67ca58b39e94ed99aa64940e4de93c2bbd (diff) | |
download | android-node-v8-a2a69a2b632e5c186f6af1bca79c349fa25580df.tar.gz android-node-v8-a2a69a2b632e5c186f6af1bca79c349fa25580df.tar.bz2 android-node-v8-a2a69a2b632e5c186f6af1bca79c349fa25580df.zip |
querystring: improve parse() performance
This commit improves parse() performance by ~20-200% with the various
querystring-parse benchmarks.
Some optimization strategies used in this commit include:
* Combining multiple searches (for '&', '=', and '+') on the same
string into a single loop
* Avoiding string.split()
* Minimizing creation of temporary strings
* Avoiding string decoding if no encoded bytes were found and the
default string decoder is being used
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>
Diffstat (limited to 'test/parallel/test-querystring.js')
-rw-r--r-- | test/parallel/test-querystring.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index b438885249..c8e9cc7050 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -248,3 +248,6 @@ qs.unescape = function(str) { }; assert.deepEqual(qs.parse('foo=bor'), {f__: 'b_r'}); qs.unescape = prevUnescape; + +// test separator and "equals" parsing order +assert.deepEqual(qs.parse('foo&bar', '&', '&'), { foo: '', bar: '' }); |