mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 07:34:32 +00:00
Reduce times of move and copy operation
This commit is contained in:
parent
e37bb0721d
commit
8aaccf1587
1 changed files with 2 additions and 2 deletions
|
@ -41,7 +41,7 @@ class lru_cache_t {
|
||||||
// The value from the client
|
// The value from the client
|
||||||
Contents value;
|
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<wcstring, lru_node_t>::iterator node_iter_t;
|
typedef typename std::unordered_map<wcstring, lru_node_t>::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
|
// 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.
|
// 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.
|
// 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)));
|
auto iter_inserted = this->node_map.emplace(std::move(key), lru_node_t(std::move(value)));
|
||||||
if (!iter_inserted.second) {
|
if (!iter_inserted.second) {
|
||||||
|
|
Loading…
Reference in a new issue