dense_map: avoid dispatching based on iterator category if possible

This commit is contained in:
Michele Caini
2022-02-28 08:38:52 +01:00
parent f432dc6bdc
commit d3c44a6fa6

View File

@@ -617,9 +617,8 @@ public:
* @return An iterator following the removed element.
*/
iterator erase(const_iterator pos) {
const auto dist = std::distance(cbegin(), pos);
erase(pos->first);
return begin() + dist;
return begin() + (pos - cbegin());
}
/**
@@ -633,7 +632,7 @@ public:
erase((last - 1u)->first);
}
return (begin() + std::distance(cbegin(), last));
return (begin() + (last - cbegin()));
}
/**