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:
parent
986ea056a9
commit
e55490b8b4
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue