-
-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(utils/url): Short circuit the regex in checkOptionalParameter #3974
perf(utils/url): Short circuit the regex in checkOptionalParameter #3974
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 I agree it's worth within the context/environment of which Hono is often applied, it's one of the optimizations that one would prefer to avoid maintaining a full fork for.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3974 +/- ##
==========================================
- Coverage 91.29% 91.29% -0.01%
==========================================
Files 168 168
Lines 10772 10771 -1
Branches 3057 3140 +83
==========================================
- Hits 9834 9833 -1
Misses 937 937
Partials 1 1 ☔ View full report in Codecov by Sentry. |
Hi @csainty Awesome! But I would like to confirm. Is the benchmark script that you used |
Yes that it correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Hey @usualoma Can you review this? |
Hi, @csainty. Thank you. Good improvement! I want to use |
Co-authored-by: Taku Amano <taku@taaas.jp>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@csainty Thank you. LGTM!
Here's a small suggestion to short-circuit the
checkOptionalParameter
check without doing a regex match when we can O(1) determine it won't match.It's a small optimization, but for the
LinearRouter
in an environment with a lot of routes it is a non-trivial improvement.Before
After:
The author should do the following, if applicable
bun run format:fix && bun run lint:fix
to format the code