Avoids string copy by working with pointers while resolving variables

This commit is contained in:
Felipe Zimmerle
2016-12-27 15:25:11 -03:00
parent 7834cf857b
commit a7f465cf3a
38 changed files with 179 additions and 94 deletions

View File

@@ -33,11 +33,20 @@ namespace collection {
class Variable {
public:
Variable(const std::string& key, const std::string& value) :
Variable(const std::string *key, const std::string *value) :
m_key(key),
m_value(value) { }
std::string m_key;
std::string m_value;
m_value(value),
m_dynamic_value(false) { }
~Variable() {
if (m_dynamic_value) {
delete m_value;
}
}
const std::string *m_key;
const std::string *m_value;
bool m_dynamic_value;
};
} // namespace collection

View File

@@ -56,7 +56,7 @@ class Rule {
void executeActionsAfterFullMatch(Transaction *trasn,
bool containsDisruptive, RuleMessage *ruleMessage);
std::vector<std::string> executeSecDefaultActionTransofrmations(
Transaction *trasn, std::string &value, bool multiMatch);
Transaction *trasn, const std::string &value, bool multiMatch);
bool executeOperatorAt(Transaction *trasn, std::string key,
std::string value);
void executeActionsIndependentOfChainedRuleResult(Transaction *trasn,

View File

@@ -361,6 +361,19 @@ class Transaction {
RequestBodyProcessor::XML *m_xml;
RequestBodyProcessor::JSON *m_json;
std::string m_variableDuration;
std::map<std::string, std::string> m_variableEnvs;
std::string m_variableHighestSeverityAction;
std::string m_variableRemoteUser;
std::string m_variableTime;
std::string m_variableTimeDay;
std::string m_variableTimeEpoch;
std::string m_variableTimeHour;
std::string m_variableTimeMin;
std::string m_variableTimeSec;
std::string m_variableTimeWDay;
std::string m_variableTimeYear;
private:
std::string *m_ARGScombinedSizeStr;
std::string *m_namesArgs;