You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimize path, join, and removeNullOrUndef functions for performance and clarity, introduce regex pre-compilation, and improve path parameter validation. (#82)
* Optimize `path` function to handle templates without parameters more efficiently.
* Optimize `join` function for common boundary scenarios and remove unused fast path logic in `path`.
* Optimize `removeNullOrUndef` to improve performance by avoiding unnecessary object allocation and using direct property iteration.
* Refactor `removeNullOrUndef` to simplify logic and avoid unnecessary null check flag.
* Optimize `path` function by pre-compiling regex to avoid recompilation overhead.
* Improve validation for path parameters by adding empty string check and clarifying allowed types.
* Update Changesets config to ignore "web" package and add initial release note template
* Add comprehensive changeset documentation for performance optimizations (#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]>
---------
Co-authored-by: Copilot <[email protected]>
Performance optimizations for path and parameter handling utilities in `src/index.ts`. This release focuses on reducing regex recompilation overhead, optimizing string manipulation for path joining, and improving parameter filtering performance.
6
+
7
+
**Performance Optimizations:**
8
+
9
+
-**Pre-compiled regex**: Extracted the path parameter regex (`PATH_PARAM_REGEX`) to module scope to avoid recompiling it on every `path()` call, improving efficiency for path template processing.
10
+
-**Optimized `join()` function**: Rewrote to use direct string indexing (`part1[len1 - 1]`, `part2[0]`) instead of `endsWith`/`startsWith` methods, added fast paths for empty strings, and optimized for the most common URL joining scenario where both parts have separators. This reduces unnecessary string slicing and improves speed.
11
+
-**Optimized `removeNullOrUndef()` function**: Improved performance by checking for null/undefined values before allocating a new object, and using direct property iteration instead of `Object.entries`/`Object.fromEntries`. This results in faster execution and less memory usage, especially when no filtering is needed.
12
+
13
+
**Parameter Validation Improvements:**
14
+
15
+
- Enhanced `validatePathParam()` to check for empty strings in path parameters, ensuring that string path parameters cannot be empty or whitespace-only values.
16
+
- Improved code readability by adding blank lines between logical blocks in validation logic.
0 commit comments