-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Apply Clang-Tidy and VS static analysis suggestions. #78957
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-requesting reviews from non-collaborators: @wapcaplet @Qrox @andrei8l
Do you know why are these issues not caught by our current clang-tidy CI setup? Is it a window-specific issue, a newer clang-tidy version that you are using or something else? |
For the commits that don't have |
We should What is your clang-tidy version? How do you obtain the binary? The (separately, the CI is failing since you probably want to add |
I don't think it makes much sense to address these unless our CI version detects them or they cause significant issues. |
|
* performance-unnecessary-copy-initialization * performance-unnecessary-value-param * performance-move-const-arg * readability-container-size-empty
clang-tidy is failing because padding on |
@@ -1251,7 +1251,7 @@ tripoint_abs_omt overmapbuffer::find_random( | |||
return find_random( origin, params ); | |||
} | |||
|
|||
shared_ptr_fast<npc> overmapbuffer::find_npc( character_id id ) | |||
shared_ptr_fast<npc> overmapbuffer::find_npc( character_id id ) const | |||
{ | |||
for( auto &it : overmaps ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you will fix these (see build errors). Commenting so that it does not fly under the radar.
I like the padding warnings. They taught us that in school but I never knew you could turn on a warning! (And never knew why you couldn't turn it on.) @moxian Is setting up clang on a local machine manageable these days? can MSVC do it for a single file without compiling the whole project for like 6 hours? |
Stock clang-tidy definitely is, but I haven't managed to build our cata plugin still. I'm away from my proper PC for the next couple of days so I can't really give a proper answer but the short of it is:
|
I missed it before, but |
Can you separate out the enum class changes to a separate PR because they're the bulk of this change and probably the least interesting parts (and makes it harder to see what may be functionally contributing to the performance wins)? |
@@ -5730,7 +5730,7 @@ void outfit_swap_actor::finish( player_activity &act, Character &who ) | |||
// Taken-off items are put in this temporary list, then naturally deleted from the world when the function returns. | |||
std::list<item> it_list; | |||
for( item_location &worn_item : who.get_visible_worn_items() ) { | |||
item outfit_component( *worn_item ); | |||
const item &outfit_component( *worn_item ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe? does taking off the worn item not invalidate the item location and then invalidate the outfit component?
Summary
Infrastructure "Apply Clang-Tidy and VS static analysis suggestions."
Purpose of change
Improve code readability and performance. On my machine this reduced mean time per
do_turn
from 135 microseconds to 131.5, around a 2.5% speedup.Describe the solution
Apply changes. There are a lot of changes but they're grouped by commit and nearly all changes are trivial.
Describe alternatives you've considered
None.
Testing
The game compiles and tests run.
Additional context