Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code optimizations reported by static code analysis (2020-02-18) #38141

Merged
merged 7 commits into from
Feb 20, 2020

Conversation

ZhilkinSerg
Copy link
Contributor

Summary

SUMMARY: Performance "Code optimizations reported by static code analysis"

Purpose of change

Cleanup code.

Describe the solution

See commit messages.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Feb 18, 2020
@pjf
Copy link
Contributor

pjf commented Feb 18, 2020

As a matter of personal interest and education, what are we using for static code analysis? Is it clang -analyze, or are these better/different options these days?

@ZhilkinSerg
Copy link
Contributor Author

PVS Studio, ReSharper C++

@pjf
Copy link
Contributor

pjf commented Feb 19, 2020

Oh, I've heard good things about ReSharper, but didn't realise it did C++ as well as C#. Thank you, @ZhilkinSerg !

items_there.erase( item_iter );
// If we didn't pick up a whole stack, put the remainder back where it came from.
if( leftovers.charges > 0 ) {
g->m.add_item_or_charges( src_loc, leftovers );
}
std::string picked_up = it.tname();
if( p.is_npc() && !picked_up.empty() ) {
Copy link
Contributor

@BevapDin BevapDin Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstance would item::tname return an empty string? It seems this check will never be false.

@kevingranade kevingranade merged commit 142295b into CleverRaven:master Feb 20, 2020
@ZhilkinSerg ZhilkinSerg deleted the sa-2020-02-18 branch February 20, 2020 02:44
kevingranade added a commit to kevingranade/Cataclysm-DDA that referenced this pull request Feb 25, 2020
…-02-18"

This reverts commit 142295b, reversing
changes made to f98c67d.
ZhilkinSerg pushed a commit that referenced this pull request Feb 25, 2020
* Revert "Moved more string consts into single file (#38237)"

This reverts commit 4987742.

* Revert "Moved more string consts into single file (#38220)"

This reverts commit d9c6079.

* Revert "Move string consts into single file (#38195)"

This reverts commit b1b48ba.

* Revert "More string consts into single file (#38189)"

This reverts commit 4fffd96.

* Revert "More string consts into single file (#38183)"

This reverts commit 05940bf.

* Revert "Move string consts into single file (#38184)"

This reverts commit 19c5698.

* Revert "Move string consts into single file (#38181)"

This reverts commit 55cabb7.

* Revert "Move more string consts into single file (#38175)"

This reverts commit 571efb2.

* Revert "Merge pull request #38176 from Ramza13/string_consts_and_more"

This reverts commit 9c9835f, reversing
changes made to 07995cd.

* Revert "Move more string consts into single file (#38169)"

This reverts commit 07995cd.

* Revert "Merge pull request #38168 from Ramza13/even_more_string_consts"

This reverts commit 2bf1c1e, reversing
changes made to 24a32c0.

* Revert "Merge pull request #38141 from ZhilkinSerg/sa-2020-02-18"

This reverts commit 142295b, reversing
changes made to f98c67d.

* Revert "Move string consts into single file (#38158)"

This reverts commit 50059c8.

* Revert "Merge pull request #38157 from Ramza13/string_consts_more_flags"

This reverts commit 8ec8e78, reversing
changes made to 72ef022.

* Revert "Move string_consts"

This reverts commit 0a6bf67.

* Revert "Merge pull request #38146 from Ramza13/battery"

This reverts commit 9286722, reversing
changes made to e9f1cd7.

* Revert "Merge pull request #38134 from AMurkin/rename-blob"

This reverts commit 06f72d2, reversing
changes made to bcfe074.

* Revert "Yet more string consts moved out (#38130)"

This reverts commit b5f18f3.

* Revert "Merge pull request #38115 from Ramza13/string_consts_game"

This reverts commit 9807657, reversing
changes made to 036465f.

* Fixup to the picked_up

* RE-inline item_location initialization

* Update character.h

* Update item.cpp

* Update item.h

* Update item_action.cpp

* Update item_factory.cpp

* Update point.h

* Update safemode_ui.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants