Use splice instead of erase/push_front

splice inserts an item into one container removing it from another
container. It seems to be what people use for this usecase in STL
LRU implementations.

Change-Id: I038aea2e3aadfce01ca30946c16fea3ce0b17b4f
This commit is contained in:
Monty Taylor 2019-04-12 20:44:40 +00:00
parent 986ea056a9
commit e55490b8b4
1 changed files with 1 additions and 2 deletions

View File

@ -69,8 +69,7 @@ public:
return {};
auto val = *(location->second);
queue.erase(location->second);
queue.push_front(val);
queue.splice(queue.begin(), queue, location->second);
return val.second;
}