Summary#
- Move
blobPattern,treePattern, andpathAfterRefREinto package-level compiled regex variables inappview/reporesolver/resolver.go. - Reuse precompiled patterns in
extractCurrentDirandextractPathAfterRefinstead of recompiling on each call. - Keep path extraction behavior unchanged while reducing per-request overhead in repo path resolution.
Why#
Regexes were being compiled repeatedly during request handling. Compiling once at package initialization avoids unnecessary work in hot paths and improves efficiency with no functional change.
Test Plan#
- Run unit tests for
appview/reporesolverpackage. - Manually verify repo view routes still resolve correctly for:
-
/blob/<ref>/<path> -
/tree/<ref>/<path> -
/raw/<ref>/<path>
-
- Confirm root and empty-path cases still return expected directories.
lgtm! Thank you for the contribution!