mirror of https://github.com/vitalif/openscad
Add debug output for the Node Id Cache.
parent
7bea0bef37
commit
4be9a43b40
22
src/Tree.cc
22
src/Tree.cc
|
@ -1,5 +1,6 @@
|
|||
#include "Tree.h"
|
||||
#include "nodedumper.h"
|
||||
#include "printutils.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
@ -31,11 +32,6 @@ const std::string &Tree::getString(const AbstractNode &node) const
|
|||
return this->nodecache[node];
|
||||
}
|
||||
|
||||
static bool filter(char c)
|
||||
{
|
||||
return c == ' ' || c == '\n' || c == '\t' || c == '\r';
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the cached ID string representation of the subtree rooted by \a node.
|
||||
If node is not cached, the cache will be rebuilt.
|
||||
|
@ -47,16 +43,22 @@ static bool filter(char c)
|
|||
const std::string &Tree::getIdString(const AbstractNode &node) const
|
||||
{
|
||||
assert(this->root_node);
|
||||
|
||||
if (!this->nodeidcache.contains(node)) {
|
||||
const std::string &str = getString(node);
|
||||
const std::string &nodestr = getString(node);
|
||||
const boost::regex re("[^\\s\\\"]+|\\\"(?:[^\\\"\\\\]|\\\\.)*\\\"");
|
||||
std::stringstream sstream;
|
||||
boost::sregex_token_iterator i(str.begin(), str.end(), re, 0);
|
||||
std::copy(i, boost::sregex_token_iterator(), std::ostream_iterator<std::string>(sstream));
|
||||
boost::sregex_token_iterator i(nodestr.begin(), nodestr.end(), re, 0);
|
||||
std::copy(i, boost::sregex_token_iterator(), std::ostream_iterator<std::string>(sstream));
|
||||
|
||||
return this->nodeidcache.insert(node, sstream.str());
|
||||
const std::string & result = this->nodeidcache.insert(node, sstream.str());
|
||||
PRINTDB("Id Cache MISS: %s", result);
|
||||
return result;
|
||||
} else {
|
||||
const std::string & result = this->nodeidcache[node];
|
||||
PRINTDB("Id Cache HIT: %s", result);
|
||||
return result;
|
||||
}
|
||||
return this->nodeidcache[node];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue