Using shared var for variables names

This commit is contained in:
Felipe Zimmerle
2018-02-02 15:41:13 -03:00
parent 6f7fdd9493
commit de7c5c89bb
21 changed files with 183 additions and 187 deletions

View File

@@ -53,10 +53,8 @@ void AnchoredSetVariable::set(const std::string &key,
const std::string &value, size_t offset, size_t len) {
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
std::string *v = new std::string(value);
std::string *k = new std::string(m_name + ":" + key);
collection::Variable *var = new collection::Variable(k, v);
collection::Variable *var = new collection::Variable(std::make_shared<std::string>(m_name + ":" + key), v);
delete v;
delete k;
origin->m_offset = offset;
origin->m_length = len;
@@ -70,10 +68,8 @@ void AnchoredSetVariable::set(const std::string &key,
const std::string &value, size_t offset) {
std::unique_ptr<VariableOrigin> origin(new VariableOrigin());
std::string *v = new std::string(value);
std::string *k = new std::string(m_name + ":" + key);
collection::Variable *var = new collection::Variable(k, v);
collection::Variable *var = new collection::Variable(std::make_shared<std::string>(m_name + ":" + key), v);
delete v;
delete k;
origin->m_offset = offset;
origin->m_length = value.size();