mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-01 20:46:56 +00:00
sstables: mark param of reverse_map() const
it does not mutate the map in which the value is looked up, so let's mark map const. also, take this opportunity to use structured binding for better readability. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -203,10 +203,10 @@ std::unordered_map<sstable::format_types, sstring, enum_hash<sstable::format_typ
|
||||
// enough. If that changes, it would be adviseable to create a full static
|
||||
// reverse mapping, even if it is done at runtime.
|
||||
template <typename Map>
|
||||
static typename Map::key_type reverse_map(const typename Map::mapped_type& value, Map& map) {
|
||||
for (auto& pair: map) {
|
||||
if (pair.second == value) {
|
||||
return pair.first;
|
||||
static typename Map::key_type reverse_map(const typename Map::mapped_type& v, const Map& map) {
|
||||
for (auto& [key, value]: map) {
|
||||
if (value == v) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
throw std::out_of_range("unable to reverse map");
|
||||
|
||||
Reference in New Issue
Block a user