Instantiates the Class variable earlier

Avoid the instantiation for every call
This commit is contained in:
Felipe Zimmerle 2017-01-18 09:13:34 -03:00 committed by Felipe Zimmerle
parent ba6b972ca8
commit 9a8fc3116a
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
2 changed files with 26 additions and 9 deletions

View File

@ -33,10 +33,16 @@ namespace collection {
class Variable {
public:
Variable(const std::string *key) :
m_key(key),
m_value(),
m_dynamic_value(false),
m_dynamic(false) { }
Variable(const std::string *key, const std::string *value) :
m_key(key),
m_value(value),
m_dynamic_value(false) { }
m_dynamic_value(false),
m_dynamic(false) { }
~Variable() {
if (m_dynamic_value) {
@ -47,6 +53,7 @@ class Variable {
const std::string *m_key;
const std::string *m_value;
bool m_dynamic_value;
bool m_dynamic;
};
} // namespace collection

View File

@ -420,8 +420,10 @@ std::vector<const collection::Variable *> Rule::getFinalVars(
trasn->debug(9, "Variable: " + *key +
" is part of the exclusion list, skipping...");
#endif
if (v->m_dynamic) {
delete v;
v = NULL;
}
continue;
}
@ -439,8 +441,10 @@ std::vector<const collection::Variable *> Rule::getFinalVars(
}
}
if (ignoreVariable) {
if (v->m_dynamic) {
delete v;
v = NULL;
}
continue;
}
@ -458,8 +462,10 @@ std::vector<const collection::Variable *> Rule::getFinalVars(
}
}
if (ignoreVariable) {
if (v->m_dynamic) {
delete v;
v = NULL;
}
continue;
}
@ -636,8 +642,10 @@ end_clean:
while (finalVars.empty() == false) {
auto *a = finalVars.back();
finalVars.pop_back();
if (a->m_dynamic) {
delete a;
}
}
return false;
@ -654,8 +662,10 @@ end_exec:
while (finalVars.empty() == false) {
auto *a = finalVars.back();
finalVars.pop_back();
if (a->m_dynamic) {
delete a;
}
}
return true;
}