From 903e7c6d5ec79adca0416e758011668f075439d0 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 18 Aug 2019 12:14:07 -0700 Subject: [PATCH] history_lru_cache_t to use move semantics --- src/history.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/history.cpp b/src/history.cpp index 9463c9790..38e1a2ef1 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -135,7 +135,7 @@ class history_lru_cache_t : public lru_cache_t(max) {} /// Function to add a history item. - void add_item(const history_item_t &item) { + void add_item(history_item_t item) { // Skip empty items. if (item.empty()) return; @@ -144,7 +144,7 @@ class history_lru_cache_t : public lru_cache_tget(key); if (node == NULL) { - this->insert(std::move(key), item); + this->insert(std::move(key), std::move(item)); } else { node->creation_timestamp = std::max(node->timestamp(), item.timestamp()); // What to do about paths here? Let's just ignore them. @@ -682,13 +682,13 @@ bool history_impl_t::rewrite_to_temporary_file(int existing_fd, int dst_fd) cons size_t cursor = 0; while (auto offset = local_file->offset_of_next_item(&cursor, 0)) { // Try decoding an old item. - const history_item_t old_item = local_file->decode_item(*offset); + history_item_t old_item = local_file->decode_item(*offset); if (old_item.empty() || deleted_items.count(old_item.str()) > 0) { continue; } // Add this old item. - lru.add_item(old_item); + lru.add_item(std::move(old_item)); } }