Awesome Reviewers

For code that executes on every request or in other hot paths (router matching, context/response creation, param decoding, JSX stringification, etc.), prioritize measured performance over assumed performance, and avoid redundant work.

Concretely:

Example: prefer hoisting a regex instead of recompiling it per call:

// Bad: regex recompiled on every call
const parseAcceptValue = (value: string) => {
  const parts = value.split(/;(?=(?:(?:[^"]*"){2})*[^"]*$)/)
  // ...
}

// Good: regex compiled once
const SPLIT_REGEX = /;(?=(?:(?:[^"]*"){2})*[^"]*$)/
const parseAcceptValue = (value: string) => {
  const parts = value.split(SPLIT_REGEX)
  // ...
}