perf(fish): migrate FORGIT_ vars without spawning subprocesses#543
perf(fish): migrate FORGIT_ vars without spawning subprocesses#543AllanZyne wants to merge 1 commit into
Conversation
The backwards-compatibility block that exports unexported FORGIT_ config variables ran `set | awk | grep` plus a `set -x | grep` for every variable, forking multiple external processes on every interactive fish startup. Replace the pipeline with fish's built-in `set -n`/`set -xn` and `string match`, which run in-process. Behavior is unchanged: unexported FORGIT_ variables are still detected, warned about, and exported; nothing is emitted when all variables are already exported. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe FORGIT_ variable export-detection logic in the Fish plugin config was rewritten to use native Fish built-ins (set -n, set -xn, string match -qr) instead of an external pipeline of set, awk, grep, and while read. ChangesVariable Export Refactor
Estimated code review effort: 2 (Simple) | ~10 minutes Compact metadata: Lines changed: +2/-2 | Base: e0c7b84 | Head: f147179 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
sandr01d
left a comment
There was a problem hiding this comment.
Nice improvement, thanks for your contribution! I'll leave the PR open over the weekend so the other maintainers have a chance to take a look and will merge it next week should there be no objections.
What
The backwards-compatibility block in
conf.d/forgit.plugin.fishthat exports unexportedFORGIT_config variables used a shell pipeline:This forks
awkandgrep(once for the list, then agrepper variable) on every interactive fish startup. I replaced it with fish's built-inset -n/set -xn+string match, which run in-process:Why
Pure startup-speed win — no external processes spawned for this block anymore. On my machine the block's cost dropped from ~2.5ms to ~1.5ms; the real benefit is eliminating the per-variable subprocess fork, which scales with how many
FORGIT_vars a user has set.Behavior
Unchanged. Verified:
FORGIT_variables are still detected, warned about, and exported.FORGIT_variables are already exported.The anchored
^FORGIT_match onset -noutput (one name per line) is equivalent to the previousgrep FORGIT_, just without the substring ambiguity.Testing
fish conf.d/forgit.plugin.fish— parses clean🤖 Generated with Claude Code
Summary by CodeRabbit
FORGIT_environment settings so they are exported more reliably.