From 4aa2d65bba94490d32ef1e79eef3d9bf56a76919 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Tue, 21 Jul 2015 22:43:44 -0700 Subject: [PATCH] Storage: Use std::forward and emplace for updates. --- src/Storage.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Storage.h b/src/Storage.h index 7d6f2ee162..5b4731914d 100644 --- a/src/Storage.h +++ b/src/Storage.h @@ -82,8 +82,10 @@ class Storage { ~Storage(); struct Update { - std::shared_ptr entry; enum Kind { kAssign, kValueUpdate, kFlagsUpdate, kDelete, kDeleteAll }; + Update(std::shared_ptr entry_, Kind kind_) + : entry(entry_), kind(kind_) {} + std::shared_ptr entry; Kind kind; }; typedef ConcurrentQueue UpdateQueue; @@ -117,9 +119,9 @@ class Storage { Storage(const Storage&) = delete; Storage& operator=(const Storage&) = delete; - void AddUpdate(std::shared_ptr entry, Update::Kind kind) { - if (m_updates_enabled) - m_updates.push(Update{entry, kind}); + template + void AddUpdate(Args&&... args) { + if (m_updates_enabled) m_updates.emplace(std::forward(args)...); } typedef llvm::StringMap> EntriesMap;