-
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
Rewrite code where MSVS gives nodiscard warnings #39941
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.
Looks good, thanks for fixing these!
src/npcmove.cpp
Outdated
if( is_too_close ) { | ||
break; | ||
} |
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.
Minor, but we could move this check before the if ( guy.lock() ) { ...
check to save a little on performance since I think this is a hot code path.
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.
This wont change anything since is_too_close is updated only after locking
each guy
.
If I understand your suggestion correctly.
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.
It could start out true though if dist <= def_radius
is true.
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 saw it. I will amend.
|
||
res.push_back( r ); | ||
return true; | ||
std::copy_if( recipes.begin(), recipes.end(), std::back_inserter( res ), |
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.
Nice and idiomatic 👍
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.
Yes, a similar code turned out to be a few lines below.
39cd8a2
to
4a5c381
Compare
Co-Authored-By: Isaac Freund <[email protected]>
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.
Thanks!
Rewrite code where MSVS gives nodiscard warnings (CleverRaven#39941)
* Rewrite code where MSVS gives nodiscard warnings * Till the end Co-Authored-By: Isaac Freund <[email protected]> * Remove unused variable Co-authored-by: Isaac Freund <[email protected]>
Summary
SUMMARY: None
Purpose of change
This, I hope, fixes bugs detected by MSVS warnings:
warning C4834: discarding return value of function with 'nodiscard' attribute.
Describe the solution
Testing
None. But it compiles.