Huge improve in the variables resolution time

This commit is contained in:
Felipe Zimmerle
2015-11-03 22:44:59 -03:00
parent 4a771f8c2c
commit e641c3cc17
15 changed files with 276 additions and 25 deletions

View File

@@ -65,6 +65,48 @@ void Variables::del(const std::string& key) {
}
void Variables::resolveSingleMatch(const std::string& var,
std::list<transaction::Variable *> *l) {
auto range = this->equal_range(var);
for (auto it = range.first; it != range.second; ++it) {
l->push_back(new transaction::Variable(var, it->second));
}
}
void Variables::resolveMultiMatches(const std::string& var,
std::list<transaction::Variable *> *l) {
size_t keySize = var.size();
auto range = this->equal_range(var);
for (auto it = range.first; it != range.second; ++it) {
l->push_back(new transaction::Variable(var, it->second));
}
for (auto& x : *this) {
if (x.first.size() <= keySize + 1) {
continue;
}
if (x.first.at(keySize) != ':') {
continue;
}
if (x.first.compare(0, keySize, var) != 0) {
continue;
}
l->push_back(new transaction::Variable(x.first, x.second));
}
}
void Variables::resolveRegularExpression(const std::string& var,
std::list<transaction::Variable *> *l) {
/* Not ready */
}
std::list<transaction::Variable *> Variables::resolve(const std::string& key,
std::list<transaction::Variable *> *l) {
auto range = this->equal_range(key);