Prefer ...
z = std::max(x - y, 0);
... over ...
z = x - y;
if (z < 0)
z = 0;
Please note that the nSinceLastSeen is intentionally skipped since nSinceLastSeen is unused and is being removed as part of #9532.
561 | @@ -562,9 +562,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) 562 | } 563 | 564 | // after fee 565 | - nAfterFee = nAmount - nPayFee; 566 | - if (nAfterFee < 0) 567 | - nAfterFee = 0; 568 | + nAfterFee = std::max(nAmount - nPayFee, (int64_t)0);
Imo this is a step back to before #4234
Good point! Updated version pushed :-)
54 | @@ -55,12 +55,10 @@ double CAddrInfo::GetChance(int64_t nNow) const 55 | double fChance = 1.0; 56 | 57 | int64_t nSinceLastSeen = nNow - nTime; 58 | - int64_t nSinceLastTry = nNow - nLastTry; 59 | + int64_t nSinceLastTry = std::max(nNow - nLastTry, (int64_t)0);
micronit: maybe use std::max<int64_t>(nNow - nLastTry, 0) to avoid a cast?
Good point! Fixed and pushed! :-)
561 | @@ -562,9 +562,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) 562 | } 563 | 564 | // after fee 565 | - nAfterFee = nAmount - nPayFee; 566 | - if (nAfterFee < 0) 567 | - nAfterFee = 0; 568 | + nAfterFee = std::max(nAmount - nPayFee, (CAmount)0);
Same here.
Fixed and pushed!
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 std::at_least or something.)
54 | @@ -55,12 +55,10 @@ double CAddrInfo::GetChance(int64_t nNow) const 55 | double fChance = 1.0; 56 | 57 | int64_t nSinceLastSeen = nNow - nTime; 58 | - int64_t nSinceLastTry = nNow - nLastTry; 59 | + int64_t nSinceLastTry = std::max<int64_t>(nNow - nLastTry, 0); 60 | 61 | if (nSinceLastSeen < 0)
why not do the same for nSinceLastSeen while you're at it for consistency? EDIT: Never mind, is being removed in https://github.com/bitcoin/bitcoin/pull/9532
ACK 660b28b modulo nit.
54 | @@ -55,10 +55,9 @@ double
55 | CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const
This is about to get removed as well, so you can drop it here.
@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?
Everything that has "priority" in its name is scheduled to be removed, so this function as well.
@MarcoFalke Fixed and pushed! Looks good? :-)
ACK c04f80b
utACK c04f80b8f703ee3924e5999f63d127f411d73f8c
@laanwj Thanks for the ping! Rebased and pushed! :-)
ACK a47da4b
Anything needed before merge? :-)
ACK a47da4b