From 93344fb28e07ffc1b57fac96e507d906928ada40 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 5 Nov 2010 12:17:40 -0700 Subject: [PATCH] Revisit std::multimap decoder Previously I changed the std::multimap decoder to minimize the number of constructor invocations. However, it could be much more expensive to copy an initialized (decoded) val_t than to copy an empty one. For example, if we are decoding std::multimap < int, std::set >. So change the code to insert a non-decoded val_t again. However, this still saves two constructor invocations over the original. Signed-off-by: Colin McCabe --- src/include/encoding.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/include/encoding.h b/src/include/encoding.h index 1a08b21ace526..defb74dc5f1a7 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -450,10 +450,10 @@ inline void decode(std::multimap& m, bufferlist::iterator& p) decode(n, p); m.clear(); while (n--) { - typename std::pair val; - decode(val.first, p); - decode(val.second, p); - m.insert(val); + typename std::pair tu; + decode(tu.first, p); + typename std::multimap::iterator it = m.insert(tu); + decode(it->second, p); } } -- 2.39.5