🐎 reworked memory prefetching for lower memory usage

This commit is contained in:
EntireTwix 2021-05-19 13:20:48 -07:00
parent 74861d8a74
commit 4d52d4c821
3 changed files with 8 additions and 9 deletions

View file

@ -84,6 +84,7 @@ Go to `{ip}/BankF/help` to see the bank's methods (also found in releases as hel
- **RESTful** API for connected services like a market, gambling, or anything else you can think of
- able to be used millions of blocks away, across dimensions, servers, **vanilla or modded**. In contrast to an in-game modded implementation that would be range limited.
- **Logging** of all transactions, configurable in (log_consts.hpp)[include/log_consts.hpp]
## Dependencies

View file

@ -1,6 +1,7 @@
#pragma once
#include <array>
#include <algorithm>
#include "log_consts.hpp"
#include "transactions.hpp"
struct Log
@ -9,19 +10,16 @@ struct Log
uint32_t end = 0;
void AddTrans(Transaction &&v)
{
if (!data.size())
if (data.size() == end)
{
data.resize(50);
data.resize(data.size()+pre_log_size); //prefetching memory
}
if (end)
{
for (uint32_t i = end; i > 0; --i)
{
data[i] = std::move(data[i - 1]);
}
}
data[0] = std::move(v);
if (end < 50)
if (end < max_log_size)
{
++end;
}

View file

@ -34,7 +34,7 @@ struct User
{
if(log_j.size())
{
log.data.resize(50);
log.data.resize(log_j.size()+pre_log_size);
log.end = log_j.size();
for(uint32_t i = 0; i < log_j.size(); ++i)
{