Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querystring: improve parse() and escape() performance #5012

Closed
wants to merge 3 commits into from

Commits on Feb 13, 2016

  1. 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
    mscdex committed Feb 13, 2016
    Configuration menu
    Copy the full SHA
    967fdf2 View commit details
    Browse the repository at this point in the history
  2. querystring: improve unescapeBuffer() performance

    Before this, v8 would deopt when an out of bounds `inIndex` would get
    passed to charCodeAt(). charCodeAt() returns NaN in such cases, so we
    directly emulate that behavior as well.
    
    Also, calls to charCodeAt() for constant strings have been replaced
    by the raw character codes and parser state is now stored as an
    integer instead of a string. Both of these provide a slight
    performance increase.
    mscdex committed Feb 13, 2016
    Configuration menu
    Copy the full SHA
    14acc95 View commit details
    Browse the repository at this point in the history
  3. 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.
    mscdex committed Feb 13, 2016
    Configuration menu
    Copy the full SHA
    3df8e85 View commit details
    Browse the repository at this point in the history