From 8aaccf15872c61ccbcf956bca0b711d0bb104620 Mon Sep 17 00:00:00 2001 From: ideal Date: Wed, 6 Nov 2019 21:23:58 +0800 Subject: [PATCH] Reduce times of move and copy operation --- src/lru.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lru.h b/src/lru.h index 68aa591ed..63fc09e52 100644 --- a/src/lru.h +++ b/src/lru.h @@ -41,7 +41,7 @@ class lru_cache_t { // The value from the client Contents value; - explicit lru_node_t(const Contents &v) : value(std::move(v)) {} + explicit lru_node_t(Contents &&v) : value(std::move(v)) {} }; typedef typename std::unordered_map::iterator node_iter_t; @@ -217,7 +217,7 @@ class lru_cache_t { // Adds a node under the given key without triggering eviction. Returns true if the node was // added, false if the node was not because a node with that key is already in the set. - bool insert_no_eviction(wcstring key, Contents value) { + bool insert_no_eviction(wcstring &&key, Contents &&value) { // Try inserting; return false if it was already in the set. auto iter_inserted = this->node_map.emplace(std::move(key), lru_node_t(std::move(value))); if (!iter_inserted.second) {