StorageEntry: Also store copy of name here.

This wastes a bit of space but is necessary for assign message generation.
This commit is contained in:
Peter Johnson
2015-07-26 10:28:20 -07:00
parent 3bc5699ba1
commit fb1b82e239
3 changed files with 11 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ bool Storage::SetEntryValue(StringRef name, std::shared_ptr<Value> value) {
if (!value) return true;
std::lock_guard<std::mutex> lock(m_mutex);
auto& entry = m_entries[name];
if (!entry) entry = std::make_shared<StorageEntry>();
if (!entry) entry = std::make_shared<StorageEntry>(name);
auto old_value = entry->value();
if (old_value && old_value->type() != value->type())
return false; // error on type mismatch
@@ -58,7 +58,7 @@ void Storage::SetEntryTypeValue(StringRef name, std::shared_ptr<Value> value) {
if (!value) return;
std::lock_guard<std::mutex> lock(m_mutex);
auto& entry = m_entries[name];
if (!entry) entry = std::make_shared<StorageEntry>();
if (!entry) entry = std::make_shared<StorageEntry>(name);
auto old_value = entry->value();
entry->set_value(value);
if (!old_value || *old_value != *value) {
@@ -551,7 +551,7 @@ next_line:
std::lock_guard<std::mutex> lock(m_mutex);
for (auto& i : entries) {
auto& entry = m_entries[i.first];
if (!entry) entry = std::make_shared<StorageEntry>();
if (!entry) entry = std::make_shared<StorageEntry>(i.first);
auto old_value = entry->value();
entry->set_value(i.second);
bool was_persist = entry->IsPersistent();