diff options
author | Marius Kintel <marius@kintel.net> | 2011-09-11 05:33:18 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-09-11 05:33:18 (GMT) |
commit | c0641d6916775309d64944ca121cc736f0c8d7a1 (patch) | |
tree | 801e0b5d67d13ff4773c5906c9cb68d271a2be02 /src/Tree.cc | |
parent | 09cc0496f7ce61e2bcbce80e067e0fac8054599a (diff) |
Reenabled PolySet caching. Pass shared_ptrs to polysets around to better manage memory
Diffstat (limited to 'src/Tree.cc')
-rw-r--r-- | src/Tree.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Tree.cc b/src/Tree.cc index a451f24..7615a3d 100644 --- a/src/Tree.cc +++ b/src/Tree.cc @@ -2,12 +2,18 @@ #include "nodedumper.h" #include <assert.h> +#include <algorithm> + +static bool filter(char c) +{ + return c == ' ' || c == '\n' || c == '\t' || c == '\r'; +} /*! - Returns the cached string representation of the subtree rootet by \a node. + Returns the cached string representation of the subtree rooted by \a node. If node is not cached, the cache will be rebuilt. */ -const std::string &Tree::getString(const AbstractNode &node) const +const std::string Tree::getString(const AbstractNode &node) const { assert(this->root_node); if (!this->nodecache.contains(node)) { @@ -17,7 +23,10 @@ const std::string &Tree::getString(const AbstractNode &node) const assert(this->nodecache.contains(*this->root_node) && "NodeDumper failed to create a cache"); } - return this->nodecache[node]; + std::string str = this->nodecache[node]; + str.erase(std::remove_if(str.begin(), str.end(), filter), str.end()); + + return str; } /*! |