}
}
- void _add(K key, V value) {
- lru.push_front(make_pair(key, value));
+ void _add(K key, V&& value) {
+ lru.emplace_front(key, std::move(value)); // can't move key because we access it below
contents[key] = lru.begin();
trim_cache();
}
void pin(K key, V val) {
Mutex::Locker l(lock);
- pinned.insert(make_pair(key, val));
+ pinned.emplace(std::move(key), std::move(val));
}
void clear_pinned(K e) {
typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator iter =
contents.find(i->first);
if (iter == contents.end())
- _add(i->first, i->second);
+ _add(i->first, std::move(i->second));
else
lru.splice(lru.begin(), lru, iter->second);
}
void add(K key, V value) {
Mutex::Locker l(lock);
- _add(key, value);
+ _add(std::move(key), std::move(value));
}
};