Skip to content

Commit

Permalink
Make AreaStore cache setting private
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed Mar 7, 2016
1 parent 095db16 commit f021db7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/areastore.cpp
Expand Up @@ -112,14 +112,14 @@ void AreaStore::serialize(std::ostream &os) const

void AreaStore::invalidateCache()
{
if (cache_enabled) {
if (m_cache_enabled) {
m_res_cache.invalidate();
}
}

void AreaStore::setCacheParams(bool enabled, u8 block_radius, size_t limit)
{
cache_enabled = enabled;
m_cache_enabled = enabled;
m_cacheblock_radius = MYMAX(block_radius, 16);
m_res_cache.setLimit(MYMAX(limit, 20));
invalidateCache();
Expand Down Expand Up @@ -148,7 +148,7 @@ void AreaStore::cacheMiss(void *data, const v3s16 &mpos, std::vector<Area *> *de

void AreaStore::getAreasForPos(std::vector<Area *> *result, v3s16 pos)
{
if (cache_enabled) {
if (m_cache_enabled) {
v3s16 mblock = getContainerPos(pos, m_cacheblock_radius);
const std::vector<Area *> *pre_list = m_res_cache.lookupCache(mblock);

Expand Down
7 changes: 3 additions & 4 deletions src/areastore.h
Expand Up @@ -62,7 +62,6 @@ class AreaStore {

// TODO change to unordered_map when we can
std::map<u32, Area> areas_map;
bool cache_enabled; // don't write to this from subclasses, only read.
public:
// Updates the area's ID
virtual bool insertArea(Area *a) = 0;
Expand All @@ -83,10 +82,10 @@ class AreaStore {
{}

AreaStore() :
cache_enabled(true),
m_cacheblock_radius(64),
m_res_cache(1000, &cacheMiss, this),
m_next_id(0)
m_next_id(0),
m_cache_enabled(true)
{
}

Expand All @@ -103,7 +102,7 @@ class AreaStore {
u8 m_cacheblock_radius; // if you modify this, call invalidateCache()
LRUCache<v3s16, std::vector<Area *> > m_res_cache;
u32 m_next_id;

bool m_cache_enabled;
};


Expand Down

0 comments on commit f021db7

Please sign in to comment.