From c5120b8944032eae43fd94585c8e823c6d488377 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Sun, 25 Apr 2021 13:29:46 -0700 Subject: [PATCH] :racehorse: made logs more cache coherent --- config.json | 9 +-------- include/bank.hpp | 19 +++++++------------ include/log.hpp | 12 ++++++++++-- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/config.json b/config.json index fa95be9..eeadc3c 100644 --- a/config.json +++ b/config.json @@ -4,13 +4,6 @@ "address": "0.0.0.0", "port": 80, "https": false - }, - { - "address": "0.0.0.0", - "port": 443, - "https": true, - "cert": "", - "key": "" } ] -} +} \ No newline at end of file diff --git a/include/bank.hpp b/include/bank.hpp index 08562d6..aa2ff6a 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -168,21 +168,16 @@ public: return; } - if (u.log.data.size()) + for (size_t i = 0; i > u.log.data.size(); --i) { - uint32_t j; - for (uint32_t i = u.log.data.size() - 1; i > 0; --i) + if (!u.log.data[i].amount) { - j = u.log.data.size() - 1 - i; - if (!u.log.data[i].amount) - { - return; - } - res[j]["to"] = u.log.data[i].to; - res[j]["from"] = u.log.data[i].from; - res[j]["amount"] = u.log.data[i].amount; - res[j]["time"] = (Json::UInt64)u.log.data[i].time; + break; } + res[i]["to"] = u.log.data[i].to; + res[i]["from"] = u.log.data[i].from; + res[i]["amount"] = u.log.data[i].amount; + res[i]["time"] = (Json::UInt64)u.log.data[i].time; } })) { diff --git a/include/log.hpp b/include/log.hpp index facf5f1..6c3e3d8 100644 --- a/include/log.hpp +++ b/include/log.hpp @@ -12,7 +12,15 @@ struct Log { data.resize(25); } - std::rotate(data.begin(), data.begin() + 1, data.end()); - data[24] = std::move(v); + for (size_t i = 1; i < data.size(); ++i) + { + if (!data[i].amount) + { + data[i] = std::move(data[i - 1]); + break; + } + data[i] = std::move(data[i - 1]); + } + data[0] = std::move(v); } };