From 69ff81c7276745fa19a537e7f3505aafcaee39f8 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Fri, 2 Jul 2021 22:41:40 -0700 Subject: [PATCH] :racehorse: Transaction names moved in --- include/transaction.h | 4 ++-- src/bank.cpp | 6 +++--- src/transaction.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/transaction.h b/include/transaction.h index 01cdaca..ff7832d 100644 --- a/include/transaction.h +++ b/include/transaction.h @@ -10,6 +10,6 @@ struct Transaction time_t time = 0; Transaction(); - Transaction(std::string from_str, std::string to_str, uint32_t amount, time_t time); - Transaction(std::string from_str, std::string to_str, uint32_t amount); + Transaction(std::string &&from_str, std::string &&to_str, uint32_t amount, time_t time); + Transaction(std::string &&from_str, std::string &&to_str, uint32_t amount); }; diff --git a/src/bank.cpp b/src/bank.cpp index 677367a..fa2d4e3 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -60,7 +60,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam BankResponse state; std::shared_lock lock{send_funds_l}; //about 10% of this function's cost #if MAX_LOG_SIZE > 0 - Transaction temp(a_name, b_name, amount); + Transaction temp(std::string(a_name), std::string(b_name), amount); if (!users.modify_if(a_name, [&temp, &state, amount](User &a) { #else if (!users.modify_if(a_name, [&state, amount](User &a) { @@ -102,7 +102,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam bool Bank::VerifyPassword(std::string_view name, std::string_view attempt) const noexcept { bool res = false; - users.if_contains(std::string(name), [&res, &attempt](const User &u) { res = (u.password == xxHashStringGen{}(attempt)); }); + users.if_contains(name.data(), [&res, &attempt](const User &u) { res = (u.password == xxHashStringGen{}(attempt)); }); return res; } @@ -136,7 +136,7 @@ bool Bank::AdminVerifyAccount(std::string_view name) noexcept return (name == admin_account); } -BankResponse Bank::AddUser(const std::string &name, std::string &&init_pass) noexcept +BankResponse Bank::AddUser(std::string &&name, std::string &&init_pass) noexcept { if (!ValidUsrname(name)) { diff --git a/src/transaction.cpp b/src/transaction.cpp index 0850e7d..6062ff8 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -1,5 +1,5 @@ #include "transaction.h" Transaction::Transaction() = default; -Transaction::Transaction(std::string from_str, std::string to_str, uint32_t amount, time_t time_val) : from(from_str), to(to_str), amount(amount), time(time_val) {} -Transaction::Transaction(std::string from_str, std::string to_str, uint32_t amount) : from(from_str), to(to_str), amount(amount) { time = std::time(NULL); } \ No newline at end of file +Transaction::Transaction(std::string &&from_str, std::string &&to_str, uint32_t amount, time_t time_val) : from(from_str), to(to_str), amount(amount), time(time_val) {} +Transaction::Transaction(std::string &&from_str, std::string &&to_str, uint32_t amount) : from(from_str), to(to_str), amount(amount) { time = std::time(NULL); } \ No newline at end of file