Repository navigation
Conversation
append_option_data() copied env_value into the per-option state on a bare occurrence, but env_value is not read again after that, so move it instead. set_env() has already copied the value by then. Coverity CID: 1688253
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The moved value has no subsequent reads, and set_env() retains an independent copy.
0 open findings
What changed in this PR
Removes an unnecessary string copy in ArgParser without changing parsing behavior.
Changes:
- Moves the local environment value into per-option state after its final use.
- Leaves copies needed by later reads unchanged.
| File | Description |
|---|---|
| src/tscore/ArgParser.cc | Replaces one copy assignment with a move assignment. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
append_option_data()copiesenv_valueinto the per-option state when an option that declares an environment variable is given without a value.env_valueis a local of that occurrence and is not read after the copy, so this moves it instead.set_env()takes its own copy of the value earlier in the same block.Coverity CID: 1688253
What changes: the copy-assignment at that line becomes a move-assignment. The ArgParser test cases in
test_tscorepass before and after.What this PR does not do: the other copies of
env_valueinappend_option_data()andCommand::parse()stay as they are. The value is read again after each of them (the bare-option state afterset_env(), and the fill loop inparse()), so moving there would be wrong.