Commit e8d7647
committed
perf(git-hook-sync): resolve the hooks directory once per drift check
driftParts computed githooks.ResolveHooksDir(repoRoot) twice on a cache
miss: once inside peekHookSource and again inside
preMergeCommitHookDrift. Each call spawns a `git rev-parse --git-path
hooks` subprocess, exactly the "never exec a subprocess per item (git
rev-parse once did)" anti-pattern docs/development/high-performance-go.md
calls out under "Skip work you don't need". Resolve it once in
driftParts and thread the result into both helpers.
The result is already cached per repoRoot for the process lifetime
(driftCache), so this halves one subprocess spawn per repo per
process rather than per file — a small but real, unambiguous win with
no measurement needed to justify avoiding a redundant fork/exec.
TestDriftParts_ResolvesHooksDirOnce substitutes a counting stub for
the new resolveHooksDir package var and asserts it is called exactly
once per driftParts cache miss.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wWQmrtb8EMbn1hDgkESqE1 parent 26fc662 commit e8d7647
2 files changed
Lines changed: 50 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| |||
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
184 | | - | |
185 | | - | |
186 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
| |||
213 | 222 | | |
214 | 223 | | |
215 | 224 | | |
216 | | - | |
| 225 | + | |
| 226 | + | |
217 | 227 | | |
218 | 228 | | |
219 | 229 | | |
| |||
231 | 241 | | |
232 | 242 | | |
233 | 243 | | |
234 | | - | |
| 244 | + | |
235 | 245 | | |
236 | 246 | | |
237 | 247 | | |
| |||
301 | 311 | | |
302 | 312 | | |
303 | 313 | | |
304 | | - | |
305 | | - | |
306 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
307 | 320 | | |
308 | 321 | | |
309 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1071 | 1071 | | |
1072 | 1072 | | |
1073 | 1073 | | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
0 commit comments