UPSTREAM PR #2459: fix(tree): deduplicate entry-finding logic#27
UPSTREAM PR #2459: fix(tree): deduplicate entry-finding logic#27
Conversation
|
The target version shows 4 instances of Additional FindingsSynchronization Overhead: The Cross-Function Impact: The 🔎 Full breakdown: Loci Inspector |
The logic for finding entries is duplicated 3 times. With an (unhealthy) smothering of generics, the common functionality can be extracted into a single function that can be reused in all places.
Instead of doing some messed up callback stuff, we can also use std::ops::ControlFlow. It is slightly more verbose, but definitely easier to read.
e31aa6d to
1531458
Compare
OverviewThis analysis covers 29,429 functions (1,132 modified, 3,016 new, 3,032 removed) across two binaries following tree path-finding deduplication refactoring. Power consumption changes are negligible: target.aarch64-unknown-linux-gnu.release.gix (+0.059%), target.aarch64-unknown-linux-gnu.release.ein (-0.018%). Net Impact: Minor (Positive). Core tree traversal functions improved 5-49%, with compiler optimizations delivering unexpected wins up to 97%. External dependency regressions (serde_json +994%, BTreeMap +334%) affect non-critical paths only. Function AnalysisPerformance-Critical Improvements:
Acceptable Trade-off:
Compiler Optimization Wins:
External Dependency Regressions (Non-Critical):
Other analyzed functions showed minor changes from compiler optimizations or external dependencies with negligible real-world impact. Additional FindingsThe refactoring successfully improved code quality (eliminated ~60 lines of duplication, cleaner control flow) while delivering net positive performance. The 🔎 Full breakdown: Loci Inspector |
167bdd1 to
3deba97
Compare
0223bcb to
bfaee00
Compare
a9e7940 to
d9d8ccd
Compare


Note
Source pull request: GitoxideLabs/gitoxide#2459
I was poking around in the tree iteration code and saw an opportunity for some deduplication.
I'm not sure if the end result is worth it: a lot of generics and fairly opaque logic (looking at the direct implementation of
Tree::peel_to_entryis... Not very satisfying :P), but I figured I'd put this here in case it is something that can be merged.I'm not sure if the
pub fn lookup_entryadheres to the style guide, but I'm more than willing to find a better solution if that is all that is in the way of fixing this.