-
Notifications
You must be signed in to change notification settings - Fork 1
Optimize path, join, and removeNullOrUndef functions for performance and clarity, introduce regex pre-compilation, and improve path parameter validation.
#82
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #82 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 191 216 +25
Branches 63 73 +10
=========================================
+ Hits 191 216 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR optimizes the path function by adding a fast-path early return for templates that don't contain parameter placeholders (:param patterns), avoiding unnecessary object cloning and regex operations.
Key changes:
- Added an early return check using
indexOf(':')to detect templates without parameters - Added blank lines to improve code readability
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #82 will improve performances by 44.55%Comparing Summary
Benchmarks breakdownFootnotes
|
8f6ceca to
03d2b97
Compare
path function to handle templates without parameters more efficiently.join function for common boundary scenarios and remove unused fast path logic in path
5e970b8 to
3ef774c
Compare
join function for common boundary scenarios and remove unused fast path logic in pathpath, join, and removeNullOrUndef functions for performance and clarity, introduce regex pre-compilation, and improve path parameter validation.
|
@copilot analyze this PR and add changesets to .changeset/petite-pumas-flash.md |
|
@copilot add to copilot instruction: How to add changesets
|
…sed fast path logic in `path`.
…essary object allocation and using direct property iteration.
…null check flag.
…nd clarifying allowed types.
…ase note template
…ns (#84) * Initial plan * Update changeset with comprehensive PR analysis and detailed optimization descriptions Co-authored-by: hckhanh <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: hckhanh <[email protected]>
|



This release focuses on performance optimizations for path and parameter handling utilities in
src/index.ts. The main improvements include reducing regex recompilation overhead, optimizing string manipulation for path joining, and making parameter filtering faster by avoiding unnecessary object allocations.Performance optimizations:
PATH_PARAM_REGEX) to avoid recompiling it on every call, improving efficiency in thepathfunction.joinfunction to use direct string indexing instead ofendsWith/startsWith, and added fast paths for empty strings and common URL joining cases, reducing unnecessary string slicing and improving speed.Parameter handling improvements:
removeNullOrUndefby checking for null/undefined values before allocating a new object, and using direct property iteration instead ofObject.entries/Object.fromEntries, resulting in faster execution and less memory usage.