Skip to content

refactor(config): split ParseConfig into tokenise, dispatch, clamp and sanitize helpers - #480

Merged
Maxaubert merged 6 commits into
mainfrom
refactor/split-parseconfig
Oct 14, 2026
Merged

Maxaubert merged 6 commits into
mainfrom
refactor/split-parseconfig

Conversation

@Maxaubert

Copy link
Copy Markdown
Owner

Closes #475

Splits ParseConfig (src/config.cpp, about 260 lines) into static helpers. Move-only, no behaviour change: every key keeps the same parser and clamp, the passes run in the same order, the try/catch stays in ParseConfig.

Extracted functions (src/config.cpp, line ranges after this PR)

Function Lines Size What moved
SanitizeBinds(Config&) 127-158 32 the unsafe-bind and extra-key-switch pass
ClampConfig(Config&, bool haveRenderScaling) 161-230 70 the clamp pass, renderScaling migration (#456), model fallback
ApplyValueKey(Config&, key, val, bool& haveRenderScaling) 235-364 130 both if/else key chains (still two chains, C1061)
ApplyEmptyableKey(Config&, key, val) 367-385 19 the exe lists and engine* keys that accept an empty value
SplitIniLine(line, key&, val&) 388-397 10 trimming, comment/blank skip, key/value split
ParseConfig (what is left) 399-417 19 BOM strip, the loop, the try/catch, the two passes

One commit per extraction; review with git diff --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change.

How move-only was checked

A moved-lines diff against origin/main (removed vs added lines as a multiset, indentation ignored). The only lines that are not pure moves:

  • the new function signatures, their one-line header comments, closing braces and the call sites;
  • continue -> return true in ApplyEmptyableKey (the caller continues on true) and continue -> return false in SplitIniLine (the caller continues on false);
  • std::string key = ... / std::string val = ... -> assignments to out parameters (the caller declares key, val per line);
  • two comments that said "below" now name ParseConfig / ApplyValueKey.

Deliberately not done

  • No key -> parser table. It would rewrite every one of the ~130 branches (not move-only), several keys are special (txSamplingMode folding, renderScaling flag, outlineColor pre-parse, the *On switches, hitchThresholdPct clamp-at-parse), and the review leaves this to the separate config-registry (X-macro) decision.
  • Helper order in the file is reverse call order (each was inserted above ParseConfig); not reordered to keep the diff a clean move.

Gates

  • build.bat check: pass (only the pre-existing fopen C4996 warnings)
  • build.bat test: 643/643 test cases, 98941 assertions, exit 0 (tests/test_config_defaults.cpp and tests/fixtures/config_defaults.txt unchanged)
  • build.bat: links Wind.exe and WindTray.exe
  • src/config_ui untouched, so no build.bat config / Playwright run.

Docs: docs/architecture/08-config-profiles.md (Parsing) now names the helpers; 09-settings-ui.md points a new setting at ApplyValueKey.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH

Maxaubert and others added 6 commits October 14, 2026 01:50
…Binds (#475)

Move-only: the lines are unchanged and run at the same point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
Move-only: the lines are unchanged and run at the same point, before SanitizeBinds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
…lueKey (#475)

Move-only (re-indented): both if/else chains keep every key's parser and order. The try/catch
stays in ParseConfig, so a throw still skips the rest and keeps the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
…yEmptyableKey (#475)

Move-only apart from 'continue' becoming 'return true' (the caller continues on true) and the two
comments that said 'below' now naming ParseConfig / ApplyValueKey.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
#475)

Move-only apart from 'continue' becoming 'return false' and the key/val declarations becoming
assignments to the out parameters (the caller declares them per line, as before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TdjopXZfsUiesYxYLYHEdH
@Maxaubert
Maxaubert merged commit ee00016 into main Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: split ParseConfig into tokenise, key dispatch, clamp and bind-sanitize helpers

1 participant