mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-24 00:49:47 +02:00
Use std::move (C++11) in map and set adaptors where possible.
In the std::map adaptor, remove the complicated iterator/insert code and go with the cpp11/unordered_map.hpp approach instead. Makes the code more consistent, avoids an extra copy, and the previous complexity was unnecessary since std::map only maps to a single element per key, unlike std::multimap.
This commit is contained in:
committed by
Jakob Petsovits
parent
e8e3052d1a
commit
9725bac5c4
@@ -42,9 +42,9 @@ struct convert<std::unordered_map<K, V>> {
|
||||
for(; p != pend; ++p) {
|
||||
K key;
|
||||
p->key.convert(key);
|
||||
p->val.convert(tmp[key]);
|
||||
p->val.convert(tmp[std::move(key)]);
|
||||
}
|
||||
tmp.swap(v);
|
||||
v = std::move(tmp);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
@@ -100,9 +100,9 @@ struct convert<std::unordered_multimap<K, V>> {
|
||||
std::pair<K, V> value;
|
||||
p->key.convert(value.first);
|
||||
p->val.convert(value.second);
|
||||
tmp.insert(value);
|
||||
tmp.insert(std::move(value));
|
||||
}
|
||||
tmp.swap(v);
|
||||
v = std::move(tmp);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user