diff options
author | Marius Kintel <marius@kintel.net> | 2012-01-06 18:10:33 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-01-09 23:01:50 (GMT) |
commit | fe3362faf825016606a8bcd60669c16965b0599c (patch) | |
tree | 1cfccc34acf462d9faefdfb8662c48cde878cbf9 /src/PolySetCache.cc | |
parent | c4695872392a6d1415752934be55c81de57de87e (diff) |
Started on cache size management: Let cache sizes be read from Preferences, measure cache sizes in bytes
Diffstat (limited to 'src/PolySetCache.cc')
-rw-r--r-- | src/PolySetCache.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/PolySetCache.cc b/src/PolySetCache.cc index 2a2da9c..cff4e88 100644 --- a/src/PolySetCache.cc +++ b/src/PolySetCache.cc @@ -6,13 +6,23 @@ PolySetCache *PolySetCache::inst = NULL; void PolySetCache::insert(const std::string &id, const shared_ptr<PolySet> &ps) { - this->cache.insert(id, new cache_entry(ps), ps ? ps->polygons.size() : 0); + this->cache.insert(id, new cache_entry(ps), ps ? ps->memsize() : 0); +} + +size_t PolySetCache::maxSize() const +{ + return this->cache.maxCost(); +} + +void PolySetCache::setMaxSize(size_t limit) +{ + this->cache.setMaxCost(limit); } void PolySetCache::print() { PRINTF("PolySets in cache: %d", this->cache.size()); - PRINTF("Polygons in cache: %d", this->cache.totalCost()); + PRINTF("PolySet cache size in bytes: %d", this->cache.totalCost()); } PolySetCache::cache_entry::cache_entry(const shared_ptr<PolySet> &ps) : ps(ps) |