Skip to content

refactor: factor duplicated parse pipeline and remove dead code#1365

Merged
henryiii merged 1 commit into
mainfrom
refactor/simplifications
Jul 1, 2026
Merged

refactor: factor duplicated parse pipeline and remove dead code#1365
henryiii merged 1 commit into
mainfrom
refactor/simplifications

Conversation

@henryiii

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Verified simplifications and dead-code removals with no intended behavior changes. Full test suite (24 tests) passes.

  • Factor the parse-completion callback pipeline (App_inl.hpp): the priority-ordered _process_callbacks/_process_help_flags sequence appeared nearly verbatim in three places (the _parse(std::vector&) subcommand path, the dot-notation subcommand path, and the config section-close path). Extracted into a new private helper App::_process_completion_callbacks(bool with_help_flags). The config path is preserved exactly by passing with_help_flags=false, which also omits _process_env() and passes the matching run_callback(false, false) (vs. run_callback(false, true) for the help-flag paths). Diffed the three copies character by character first.
  • Dedup parse() prologue: the identical clear/validate/configure prologue shared by parse(std::vector&) and the rvalue overload is now a small App::_parse_setup() helper. Additionally, the rvalue _parse now checks the return value of _parse_single and breaks on false, matching the lvalue overload (currently unreachable for the rvalue path since it is top-level only, but cheap insurance).
  • Reversed-copy construction: rargs.resize(...); std::reverse_copy(...) replaced with range-construction std::vector<std::string> rargs(args.rbegin(), args.rend()).
  • _process_extras redundant recomputation: the SeparatorOnly branch built the remaining list up to three times; it now computes remaining(false) once. The remaining_size() guard is intentionally kept (it counts non-POSITIONAL_MARK entries only, so it is not equivalent to remaining(false).empty()), preserving exact behavior.
  • Dead skipSection variable (Option_inl.hpp): removed the always-false skipSection and its if(!skipSection) guard; the branch now returns unconditionally.
  • Dead commented-out code (StringTools_inl.hpp): removed the old escapedChars array experiments.
  • remove_quotes(std::string&) duplicated remove_outer: rewritten to delegate to remove_outer, and added the previously-missing declaration of remove_outer to StringTools.hpp.
  • Timer GCC 4.7 workarounds (Timer.hpp): removed the _GLIBCXX_USE_NANOSLEEP define (targeted GCC < 4.8, below the documented minimum; the library doesn't call sleep_for) and replaced the AutoTimer constructor reimplementation with using Timer::Timer;. TimerTest passes.
  • Dead '\r' checks in the multiline config writer (Config_inl.hpp): the multiline branch is only reachable when is_printable(arg) is true, which excludes '\r' (it is neither isprint nor '\n'/'\t', so it diverts to binary_escape_string). Removed the unreachable || arg.front() == '\r' / || arg.back() == '\r' halves.

Part of #1357

No behavior changes. Several verified simplifications and dead-code removals.

Assisted-by: ClaudeCode:claude-opus-4-8
@henryiii henryiii marked this pull request as ready for review June 16, 2026 04:22
@henryiii henryiii merged commit a9c853e into main Jul 1, 2026
70 checks passed
@henryiii henryiii deleted the refactor/simplifications branch July 1, 2026 20:15
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.

1 participant