diff --git a/lib/querystring.js b/lib/querystring.js index 0eaaca57b08117..b4851f57c3e4e0 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -285,7 +285,6 @@ function parse(qs, sep, eq, options) { } const customDecode = (decode !== qsUnescape); - const keys = []; var lastPos = 0; var sepIdx = 0; var eqIdx = 0; @@ -326,11 +325,8 @@ function parse(qs, sep, eq, options) { if (value.length > 0 && valEncoded) value = decodeStr(value, decode); - // Use a key array lookup instead of using hasOwnProperty(), which is - // slower - if (keys.indexOf(key) === -1) { + if (obj[key] === undefined) { obj[key] = value; - keys[keys.length] = key; } else { const curValue = obj[key]; // A simple Array-specific property check is enough here to @@ -428,10 +424,8 @@ function parse(qs, sep, eq, options) { key = decodeStr(key, decode); if (value.length > 0 && valEncoded) value = decodeStr(value, decode); - // Use a key array lookup instead of using hasOwnProperty(), which is slower - if (keys.indexOf(key) === -1) { + if (obj[key] === undefined) { obj[key] = value; - keys[keys.length] = key; } else { const curValue = obj[key]; // A simple Array-specific property check is enough here to