🎨 simplified DelUser()

This commit is contained in:
EntireTwix 2021-07-03 19:10:32 -07:00
parent 029a10f1bc
commit a561742347

View file

@ -187,17 +187,18 @@ BankResponse Bank::DelUser(const std::string &name) noexcept
std::shared_lock<std::shared_mutex> lock{size_l}; std::shared_lock<std::shared_mutex> lock{size_l};
#if RETURN_ON_DEL #if RETURN_ON_DEL
uint32_t bal; uint32_t bal;
if (users.erase_if(name, [this, &bal, &name](User &u) { if (users.if_contains(name, [this, &bal](const User &u) {
bal = u.balance; bal = u.balance;
return true;
})) }))
#else
if (users.erase(name))
#endif
{ {
#if RETURN_ON_DEL users.modify_if(return_account, [ this, bal ](User & u))
users.modify_if(return_account, [&bal](User &u) { u.balance += bal; }); {
u.balance += bal;
}
}
#endif #endif
if (users.erase(name))
{
#if CONSERVATIVE_DISK_SAVE #if CONSERVATIVE_DISK_SAVE
#if MULTI_THREADED #if MULTI_THREADED
save_flag.SetChangesOn(); save_flag.SetChangesOn();