dout(12) << "[ get table ] = " << signature << dendl;
// we try to fetch a decoding table from an LRU cache
- bool found = false;
-
std::lock_guard lock{codec_tables_guard};
lru_map_t* decode_tbls_map =
lru_list_t* decode_tbls_lru =
getDecodingTablesLru(matrixtype);
- if (decode_tbls_map->count(signature)) {
- dout(12) << "[ cached table ] = " << signature << dendl;
- // copy the table out of the cache
- memcpy(table, (*decode_tbls_map)[signature].second.c_str(), k * (m + k)*32);
- // find item in LRU queue and push back
- dout(12) << "[ cache size ] = " << decode_tbls_lru->size() << dendl;
- decode_tbls_lru->splice( (decode_tbls_lru->begin()), *decode_tbls_lru, (*decode_tbls_map)[signature].first);
- found = true;
+ auto lru_map_it = decode_tbls_map->find(signature);
+ if (lru_map_it == decode_tbls_map->end()) {
+ return false;
}
-
- return found;
+ const auto& [lru_list_it, cached_table] = lru_map_it->second;
+ dout(12) << "[ cached table ] = " << signature << dendl;
+ // copy the table out of the cache
+ memcpy(table, cached_table.c_str(), k * (m + k)*32);
+ // find item in LRU queue and push back
+ dout(12) << "[ cache size ] = " << decode_tbls_lru->size() << dendl;
+ decode_tbls_lru->splice( (decode_tbls_lru->begin()), *decode_tbls_lru, lru_list_it);
+ return true;
}
// -----------------------------------------------------------------------------