-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Use z = std::max(x - y, 0) instead of z = x - y; if (z < 0) z = 0; #9553
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
Conversation
433bb96
to
bb35501
Compare
src/qt/coincontroldialog.cpp
Outdated
nAfterFee = nAmount - nPayFee; | ||
if (nAfterFee < 0) | ||
nAfterFee = 0; | ||
nAfterFee = std::max(nAmount - nPayFee, (int64_t)0); |
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.
Imo this is a step back to before #4234
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.
Good point! Updated version pushed :-)
bb35501
to
63c8eb0
Compare
src/addrman.cpp
Outdated
@@ -55,12 +55,10 @@ double CAddrInfo::GetChance(int64_t nNow) const | |||
double fChance = 1.0; | |||
|
|||
int64_t nSinceLastSeen = nNow - nTime; | |||
int64_t nSinceLastTry = nNow - nLastTry; | |||
int64_t nSinceLastTry = std::max(nNow - nLastTry, (int64_t)0); |
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.
micronit: maybe use std::max<int64_t>(nNow - nLastTry, 0)
to avoid a cast?
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.
Good point! Fixed and pushed! :-)
src/qt/coincontroldialog.cpp
Outdated
nAfterFee = nAmount - nPayFee; | ||
if (nAfterFee < 0) | ||
nAfterFee = 0; | ||
nAfterFee = std::max(nAmount - nPayFee, (CAmount)0); |
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.
Same here.
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.
Fixed and pushed!
63c8eb0
to
660b28b
Compare
I think it's actually more readable the longer way in some cases, but don't care strongly. (I would probably think differently if there was an alias called |
src/addrman.cpp
Outdated
@@ -55,12 +55,10 @@ double CAddrInfo::GetChance(int64_t nNow) const | |||
double fChance = 1.0; | |||
|
|||
int64_t nSinceLastSeen = nNow - nTime; | |||
int64_t nSinceLastTry = nNow - nLastTry; | |||
int64_t nSinceLastTry = std::max<int64_t>(nNow - nLastTry, 0); | |||
|
|||
if (nSinceLastSeen < 0) |
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.
why not do the same for nSinceLastSeen while you're at it for consistency?
EDIT: Never mind, is being removed in #9532
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.
ACK 660b28b |
src/txmempool.cpp
Outdated
@@ -55,10 +55,9 @@ double | |||
CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const |
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 is about to get removed as well, so you can drop it here.
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.
@MarcoFalke What should be dropped? Sorry, didn't catch that :-)
Do you mean that the changes to src/txmempool.cpp
should be excluded from this commit?
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.
Everything that has "priority" in its name is scheduled to be removed, so this function as well.
660b28b
to
c04f80b
Compare
@MarcoFalke Fixed and pushed! Looks good? :-) |
ACK c04f80b |
utACK c04f80b8f703ee3924e5999f63d127f411d73f8c
|
Needs rebase after #9532 |
c04f80b
to
a47da4b
Compare
@laanwj Thanks for the ping! Rebased and pushed! :-) |
ACK a47da4b |
Anything needed before merge? :-) |
ACK a47da4b |
… 0) z = 0; a47da4b Use z = std::max(x - y, 0); instead of z = x - y; if (z < 0) z = 0; (practicalswift)
…if (z < 0) z = 0; a47da4b Use z = std::max(x - y, 0); instead of z = x - y; if (z < 0) z = 0; (practicalswift)
…if (z < 0) z = 0; a47da4b Use z = std::max(x - y, 0); instead of z = x - y; if (z < 0) z = 0; (practicalswift)
…if (z < 0) z = 0; a47da4b Use z = std::max(x - y, 0); instead of z = x - y; if (z < 0) z = 0; (practicalswift)
Prefer ...
... over ...
... as suggested by @robmcl4.
Please note that the
nSinceLastSeen
is intentionally skipped sincenSinceLastSeen
is unused and is being removed as part of #9532.