Storage: Use std::forward and emplace for updates.

This commit is contained in:
Peter Johnson
2015-07-21 22:43:44 -07:00
parent bb5848a033
commit 4aa2d65bba

View File

@@ -82,8 +82,10 @@ class Storage {
~Storage();
struct Update {
std::shared_ptr<StorageEntry> entry;
enum Kind { kAssign, kValueUpdate, kFlagsUpdate, kDelete, kDeleteAll };
Update(std::shared_ptr<StorageEntry> entry_, Kind kind_)
: entry(entry_), kind(kind_) {}
std::shared_ptr<StorageEntry> entry;
Kind kind;
};
typedef ConcurrentQueue<Update> UpdateQueue;
@@ -117,9 +119,9 @@ class Storage {
Storage(const Storage&) = delete;
Storage& operator=(const Storage&) = delete;
void AddUpdate(std::shared_ptr<StorageEntry> entry, Update::Kind kind) {
if (m_updates_enabled)
m_updates.push(Update{entry, kind});
template <typename... Args>
void AddUpdate(Args&&... args) {
if (m_updates_enabled) m_updates.emplace(std::forward<Args>(args)...);
}
typedef llvm::StringMap<std::shared_ptr<StorageEntry>> EntriesMap;