summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-09 04:10:33 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-09 04:10:33 (GMT)
commit09cc0496f7ce61e2bcbce80e067e0fac8054599a (patch)
tree76905edf7f13f5bea18be54edfc98a64d994e382
parentcbba974d3ac1edeb716a1384a2262ed5447fa9e6 (diff)
Make PolySet cache global
-rw-r--r--src/PolySetEvaluator.cc10
-rw-r--r--src/PolySetEvaluator.h6
2 files changed, 9 insertions, 7 deletions
diff --git a/src/PolySetEvaluator.cc b/src/PolySetEvaluator.cc
index 2808686..6426d6e 100644
--- a/src/PolySetEvaluator.cc
+++ b/src/PolySetEvaluator.cc
@@ -9,13 +9,15 @@
class.
*/
+QCache<std::string, PolySetEvaluator::cache_entry> PolySetEvaluator::cache(100000);
+
PolySet *PolySetEvaluator::getPolySet(const AbstractNode &node)
{
const string &cacheid = this->tree.getString(node);
- if (this->cache.contains(cacheid)) return this->cache[cacheid]->ps;
+ if (cache.contains(cacheid)) return cache[cacheid]->ps;
PolySet *ps = node.evaluate_polyset(this);
- this->cache.insert(cacheid, new cache_entry(ps), ps?ps->polygons.size():0);
+ cache.insert(cacheid, new cache_entry(ps), ps?ps->polygons.size():0);
return ps;
}
@@ -27,6 +29,6 @@ PolySetEvaluator::cache_entry::cache_entry(PolySet *ps)
void PolySetEvaluator::printCache()
{
- PRINTF("PolySets in cache: %d", this->cache.size());
- PRINTF("Polygons in cache: %d", this->cache.totalCost());
+ PRINTF("PolySets in cache: %d", cache.size());
+ PRINTF("Polygons in cache: %d", cache.totalCost());
}
diff --git a/src/PolySetEvaluator.h b/src/PolySetEvaluator.h
index 1a97cb5..b7c490d 100644
--- a/src/PolySetEvaluator.h
+++ b/src/PolySetEvaluator.h
@@ -9,7 +9,7 @@
class PolySetEvaluator
{
public:
- PolySetEvaluator(const Tree &tree) : cache(100000), tree(tree) {}
+ PolySetEvaluator(const Tree &tree) : tree(tree) {}
virtual ~PolySetEvaluator() {}
const Tree &getTree() const { return this->tree; }
@@ -23,7 +23,7 @@ public:
virtual PolySet *evaluatePolySet(const class RenderNode &) { return NULL; }
void clearCache() {
- this->cache.clear();
+ cache.clear();
}
void printCache();
protected:
@@ -35,7 +35,7 @@ protected:
~cache_entry() { }
};
- QCache<std::string, cache_entry> cache;
+ static QCache<std::string, cache_entry> cache;
private:
const Tree &tree;
contact: Jan Huwald // Impressum