summaryrefslogtreecommitdiffstats
path: root/staging_vespalib
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2017-03-20 13:04:33 +0000
committerHaavard <havardpe@yahoo-inc.com>2017-03-27 09:53:26 +0000
commit23abed1a0bc4f4c5ea47b43fc7ea0645e63a26e6 (patch)
tree6d943bbe31738f7e9b84979e4fd63dfd76eef580 /staging_vespalib
parent8844ccb7297e8a5120dd903c85e923f2f93aa693 (diff)
remove most usage of LinkedPtr from vespa
Diffstat (limited to 'staging_vespalib')
-rw-r--r--staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h7
-rw-r--r--staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp10
2 files changed, 17 insertions, 0 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h
index be16b1de5e2..3ca5f0ea2e8 100644
--- a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h
+++ b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.h
@@ -20,6 +20,7 @@ struct LinkedValue : public LinkedValueBase
{
LinkedValue() {}
LinkedValue(const V & v) : LinkedValueBase(), _value(v) { }
+ LinkedValue(V && v) : LinkedValueBase(), _value(std::move(v)) { }
V _value;
};
@@ -125,6 +126,12 @@ public:
insert_result insert(const K & key, const V & value);
/**
+ * Object is inserted in cache with given key.
+ * Object is then put at head of LRU list.
+ */
+ insert_result insert(const K & key, V && value);
+
+ /**
* Return the object with the given key. If it does not exist an empty one will be created.
* This can be used as an insert.
* Object is then put at head of LRU list.
diff --git a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp
index 3301abca3ba..f32f1027fb6 100644
--- a/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp
+++ b/staging_vespalib/src/vespa/vespalib/stllike/lrucache_map.hpp
@@ -17,6 +17,16 @@ lrucache_map<P>::insert(const K & key, const V & value) {
}
template< typename P >
+typename lrucache_map<P>::insert_result
+lrucache_map<P>::insert(const K & key, V && value) {
+ insert_result res = insert(value_type(key, LV(std::move(value))));
+ if (res.second) {
+ onInsert(key);
+ }
+ return res;
+}
+
+template< typename P >
bool
lrucache_map<P>::removeOldest(const value_type & v) {
(void) v;