Skip to content

Commit

Permalink
fix: faster for loop (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdamAme-x authored Jan 28, 2024
1 parent 44ba4e6 commit 12afdf2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pico.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ export const Pico = (): PicoType => {
} = {
fetch: (req, env, executionContext) => {
const m = req.method
for (const route of routes) {
for (let i = 0, len = routes.length; i < len; i++) {
const route = routes[i]
const result = route.p.exec(req.url)
if ((result && route.m === 'ALL') || (result && route.m === m)) {
if ((result && route.m === 'ALL') || (result && route.m === m))
return route.h({
req,
env,
executionContext,
result,
})
}
}
},
on: (method, path, handler) => {
Expand Down

0 comments on commit 12afdf2

Please sign in to comment.