Skip to content
Myr

perf: use `indexOf()` intead of `includes()` (#1150)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent 4263d37 · Browse files · 2 files+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−3 removed

  • other:+3 added−3 removed

2 files+3 added−3 removed

modified:src/router/reg-exp-router/router.ts+1 added-1 removed
115 unmodified lines
116 if (!middleware || !routes) {117 throw new Error('Can not add a route since the matcher is already built.')118 }119120 if (!methodNames.includes(method)) methodNames.push(method)120 if (methodNames.indexOf(method) === -1) methodNames.push(method)121 if (!middleware[method]) {122 ;[middleware, routes].forEach((handlerMap) => {123 handlerMap[method] = {}124 Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
135 unmodified lines
modified:src/utils/url.ts+2 added-2 removed
130 unmodified lines
131const _decodeURI = (value: string) => {132 if (!/[%+]/.test(value)) {133 return value134 }135 if (value.includes('+')) {135 if (value.indexOf('+') !== -1) {136 value = value.replace(/\+/g, ' ')137 }138 return value.includes('%') ? decodeURIComponent_(value) : value138 return value.indexOf('%') === -1 ? value : decodeURIComponent_(value)139}140141const _getQueryParam = (142 url: string,
93 unmodified lines