Skip to content

Commit

Permalink
Fix on key type
Browse files Browse the repository at this point in the history
  • Loading branch information
Coldwings committed Jul 9, 2024
1 parent e8bf383 commit a8b6878
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/objectcachev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ class ObjectCacheV2 {
}

template <typename KeyType>
Box* __find_or_create_item(const KeyType& key) {
Box* __find_or_create_item(KeyType&& key) {
Box keyitem(key);
auto pkey = &keyitem;
Box* item = nullptr;
SCOPED_LOCK(maplock);
auto it = map.find(pkey);
if (it == map.end()) {
item = new Box(key);
item = new Box(std::forward<KeyType>(key));
map.emplace(item);
} else
item = *it;
Expand Down Expand Up @@ -217,7 +217,7 @@ class ObjectCacheV2 {

template <typename KeyType>
Borrow borrow(KeyType&& key) {
return borrow(&key, [&]() { return new V(); });
return borrow(std::forward<KeyType>(key), [&]() { return new V(); });
}

template <typename KeyType, typename Ctor>
Expand Down

0 comments on commit a8b6878

Please sign in to comment.