mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 20:47:10 +11:00
⚡ small tweaksg
This commit is contained in:
parent
0f50e00b6c
commit
7ce9a71118
1 changed files with 5 additions and 3 deletions
|
|
@ -184,11 +184,11 @@ BankResponse Bank::ImpactBal(const std::string &name, int64_t amount) noexcept
|
||||||
{
|
{
|
||||||
return {k400BadRequest, "\"Amount cannot be 0\""};
|
return {k400BadRequest, "\"Amount cannot be 0\""};
|
||||||
}
|
}
|
||||||
uint32_t balance;
|
uint32_t bal;
|
||||||
if (ValidUsername(name) && Bank::users.modify_if(name, [&balance, amount](User &u) { balance = (u.balance < (amount * -1) ? u.balance = 0 : u.balance += amount); }))
|
if (ValidUsername(name) && Bank::users.modify_if(name, [&bal, amount](User &u) { bal = (u.balance < (amount * -1) ? u.balance = 0 : u.balance += amount); }))
|
||||||
{
|
{
|
||||||
SET_CHANGES_ON;
|
SET_CHANGES_ON;
|
||||||
return {k200OK, std::to_string(balance)}; //may return new balance
|
return {k200OK, std::to_string(bal)}; //may return new balance
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -207,7 +207,9 @@ BankResponse Bank::PruneUsers(uint32_t threshold_bal) noexcept
|
||||||
{
|
{
|
||||||
std::unique_lock<std::shared_mutex> lock{iter_lock};
|
std::unique_lock<std::shared_mutex> lock{iter_lock};
|
||||||
size_t deleted_count = 0;
|
size_t deleted_count = 0;
|
||||||
|
#if RETURN_ON_DEL
|
||||||
uint32_t bal = 0;
|
uint32_t bal = 0;
|
||||||
|
#endif
|
||||||
for (const auto &u : users)
|
for (const auto &u : users)
|
||||||
{
|
{
|
||||||
#if RETURN_ON_DEL
|
#if RETURN_ON_DEL
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue