refactor: factor duplicated parse pipeline and remove dead code#1365
Merged
Conversation
No behavior changes. Several verified simplifications and dead-code removals. Assisted-by: ClaudeCode:claude-opus-4-8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Verified simplifications and dead-code removals with no intended behavior changes. Full test suite (24 tests) passes.
App_inl.hpp): the priority-ordered_process_callbacks/_process_help_flagssequence 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 helperApp::_process_completion_callbacks(bool with_help_flags). The config path is preserved exactly by passingwith_help_flags=false, which also omits_process_env()and passes the matchingrun_callback(false, false)(vs.run_callback(false, true)for the help-flag paths). Diffed the three copies character by character first.parse()prologue: the identical clear/validate/configure prologue shared byparse(std::vector&)and the rvalue overload is now a smallApp::_parse_setup()helper. Additionally, the rvalue_parsenow checks the return value of_parse_singleand breaks onfalse, matching the lvalue overload (currently unreachable for the rvalue path since it is top-level only, but cheap insurance).rargs.resize(...); std::reverse_copy(...)replaced with range-constructionstd::vector<std::string> rargs(args.rbegin(), args.rend())._process_extrasredundant recomputation: theSeparatorOnlybranch built the remaining list up to three times; it now computesremaining(false)once. Theremaining_size()guard is intentionally kept (it counts non-POSITIONAL_MARKentries only, so it is not equivalent toremaining(false).empty()), preserving exact behavior.skipSectionvariable (Option_inl.hpp): removed the always-falseskipSectionand itsif(!skipSection)guard; the branch now returns unconditionally.StringTools_inl.hpp): removed the oldescapedCharsarray experiments.remove_quotes(std::string&)duplicatedremove_outer: rewritten to delegate toremove_outer, and added the previously-missing declaration ofremove_outertoStringTools.hpp.Timer.hpp): removed the_GLIBCXX_USE_NANOSLEEPdefine (targeted GCC < 4.8, below the documented minimum; the library doesn't callsleep_for) and replaced theAutoTimerconstructor reimplementation withusing Timer::Timer;. TimerTest passes.'\r'checks in the multiline config writer (Config_inl.hpp): the multiline branch is only reachable whenis_printable(arg)is true, which excludes'\r'(it is neitherisprintnor'\n'/'\t', so it diverts tobinary_escape_string). Removed the unreachable|| arg.front() == '\r'/|| arg.back() == '\r'halves.Part of #1357