From 9679e18ef42554bd3577347b7b823a35c469907e Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Tue, 7 Apr 2026 14:24:54 -0700 Subject: [PATCH] perf(config): cache isGitIgnored result per process lifetime (#1898) loadConfig() calls isGitIgnored() which spawns a git check-ignore subprocess. The result is stable for the process lifetime but was being recomputed on every call. With 28+ loadConfig call sites, this could spawn multiple redundant git subprocesses per CLI invocation. A module-level Map cache keyed on (cwd, targetPath) ensures the subprocess fires at most once per unique pair per process. Co-authored-by: Claude Opus 4.6 --- get-shit-done/bin/lib/core.cjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/get-shit-done/bin/lib/core.cjs b/get-shit-done/bin/lib/core.cjs index 0974c1226..394f2eb66 100644 --- a/get-shit-done/bin/lib/core.cjs +++ b/get-shit-done/bin/lib/core.cjs @@ -400,7 +400,11 @@ function loadConfig(cwd) { // ─── Git utilities ──────────────────────────────────────────────────────────── +const _gitIgnoredCache = new Map(); + function isGitIgnored(cwd, targetPath) { + const key = cwd + '::' + targetPath; + if (_gitIgnoredCache.has(key)) return _gitIgnoredCache.get(key); try { // --no-index checks .gitignore rules regardless of whether the file is tracked. // Without it, git check-ignore returns "not ignored" for tracked files even when @@ -412,8 +416,10 @@ function isGitIgnored(cwd, targetPath) { cwd, stdio: 'pipe', }); + _gitIgnoredCache.set(key, true); return true; } catch { + _gitIgnoredCache.set(key, false); return false; } }