summaryrefslogtreecommitdiff
path: root/src/core/smallmap_type.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r--src/core/smallmap_type.hpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp
index 0bd9bd296..0917c5423 100644
--- a/src/core/smallmap_type.hpp
+++ b/src/core/smallmap_type.hpp
@@ -143,9 +143,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
inline bool Insert(const T &key, const U &data)
{
if (this->Contains(key)) return false;
- Pair *n = this->Append();
- n->first = key;
- n->second = data;
+ std::vector<Pair>::emplace_back(key, data);
return true;
}
@@ -160,9 +158,10 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
for (uint i = 0; i < std::vector<Pair>::size(); i++) {
if (key == std::vector<Pair>::operator[](i).first) return std::vector<Pair>::operator[](i).second;
}
- Pair *n = this->Append();
- n->first = key;
- return n->second;
+ /*C++17: Pair &n = */ std::vector<Pair>::emplace_back();
+ Pair &n = std::vector<Pair>::back();
+ n.first = key;
+ return n.second;
}
inline void SortByKey()