diff options
-rw-r--r-- | binaryurp/source/cache.hxx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/binaryurp/source/cache.hxx b/binaryurp/source/cache.hxx index d1c1df7e32bf..722e7494bd8e 100644 --- a/binaryurp/source/cache.hxx +++ b/binaryurp/source/cache.hxx @@ -55,26 +55,25 @@ public: } // try to insert into the map list_.push_front( rContent); // create a temp entry - typedef std::pair<typename LruItMap::iterator,bool> MapPair; - MapPair aMP = map_.emplace( list_.begin(), 0 ); - *pbFound = !aMP.second; + auto const [it, inserted] = map_.emplace( list_.begin(), 0 ); + *pbFound = !inserted; - if( !aMP.second) { // insertion not needed => found the entry + if( !inserted) { // insertion not needed => found the entry list_.pop_front(); // remove the temp entry - list_.splice( list_.begin(), list_, aMP.first->first); // the found entry is moved to front - return aMP.first->second; + list_.splice( list_.begin(), list_, it->first); // the found entry is moved to front + return it->second; } // test insertion successful => it was new so we keep it IdxType n = static_cast<IdxType>( map_.size() - 1); if( n >= size_) { // cache full => replace the LRU entry // find the least recently used element in the map - typename LruItMap::iterator it = map_.find( --list_.end()); - n = it->second; - map_.erase( it); // remove it from the map + typename LruItMap::iterator lru = map_.find( --list_.end()); + n = lru->second; + map_.erase( lru); // remove it from the map list_.pop_back(); // remove from the list } - aMP.first->second = n; + it->second = n; return n; } |