Skip to content

Commit 3694fbc

Browse files
committed
perf(urlencoded): move empty-body guard to avoid extra function closure
1 parent e15bdfd commit 3694fbc

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

lib/types/urlencoded.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ function urlencoded (options) {
3939
}
4040

4141
// create the appropriate query parser
42-
var queryparse = createQueryParser(options)
43-
44-
function parse (body, encoding) {
45-
return body.length
46-
? queryparse(body, encoding)
47-
: {}
48-
}
42+
const parse = createQueryParser(options)
4943

5044
const readOptions = {
5145
...normalizedOptions,
@@ -86,7 +80,9 @@ function createQueryParser (options) {
8680
parameterLimit = parameterLimit | 0
8781
}
8882

89-
return function queryparse (body, encoding) {
83+
return function parse (body, encoding) {
84+
if (!body.length) return {}
85+
9086
var paramCount = parameterCount(body, parameterLimit)
9187

9288
if (paramCount === undefined) {

0 commit comments

Comments
 (0)