diff options
author | Henry Wilson <m3henry@googlemail.com> | 2019-02-18 22:39:06 +0000 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2019-03-26 20:15:57 +0000 |
commit | a0f36a50e6324f570985f5010eb0543ec0673aeb (patch) | |
tree | 09f9c9abd097acc244f80366da42cb8702c7ed19 /src/core/smallmap_type.hpp | |
parent | ca2f33c6d025c0c45fb4bc472493290445312de5 (diff) | |
download | openttd-a0f36a50e6324f570985f5010eb0543ec0673aeb.tar.xz |
Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back()
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r-- | src/core/smallmap_type.hpp | 11 |
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() |