Skip to content

Commit ef9e6e8

Browse files
committed
Remove pre-created EMPTY_PARAMS object and use Object.create(null)
1 parent fafa866 commit ef9e6e8

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

lib/router/sequential.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ module.exports = (config = {}) => {
4040

4141
const routers = {}
4242

43-
/**
44-
* Pre-create frozen empty objects for better performance and safety.
45-
* Use Object.create(null) for prototype pollution protection.
46-
* Frozen objects prevent accidental mutation that could cause cross-request state pollution.
47-
* These are reused across requests when no query params or route params are present.
48-
*/
49-
const EMPTY_PARAMS = Object.freeze(Object.create(null))
50-
5143
/**
5244
* Initialize LRU cache for route matching results with optimized settings.
5345
* Cache keys are method+path combinations to speed up repeated lookups.
@@ -161,7 +153,7 @@ module.exports = (config = {}) => {
161153
// Optimized parameter assignment with minimal overhead
162154
if (!req.params) {
163155
// Use pre-created empty object or provided params directly
164-
req.params = params || EMPTY_PARAMS
156+
req.params = params || Object.create(null)
165157
} else if (params) {
166158
// Manual property copying - optimized for small objects
167159
// Pre-compute keys and length to avoid repeated calls

0 commit comments

Comments
 (0)