Add AutoTimer to folly
[folly.git] / folly / dynamic-inl.h
index 81f063fb0a805bf3ae0da060db73cb933f633d67..c2d48eba36333c69585c18681c812c42cd2bb504 100644 (file)
@@ -636,15 +636,8 @@ inline dynamic::const_item_iterator dynamic::find(dynamic const& key) const {
 
 template<class K, class V> inline void dynamic::insert(K&& key, V&& val) {
   auto& obj = get<ObjectImpl>();
-  auto rv = obj.insert(std::make_pair(std::forward<K>(key),
-                                      std::forward<V>(val)));
-  if (!rv.second) {
-    // note, the second use of std:forward<V>(val) is only correct
-    // if the first one did not result in a move. obj[key] = val
-    // would be preferrable but doesn't compile because dynamic
-    // is (intentionally) not default constructable
-    rv.first->second = std::forward<V>(val);
-  }
+  auto rv = obj.insert({ std::forward<K>(key), nullptr });
+  rv.first->second = std::forward<V>(val);
 }
 
 inline std::size_t dynamic::erase(dynamic const& key) {
@@ -957,7 +950,7 @@ class FormatValue<detail::DefaultValueWrapper<dynamic, V>> {
     case dynamic::ARRAY:
       {
         int key = arg.splitIntKey();
-        if (key >= 0 && key < c.size()) {
+        if (key >= 0 && size_t(key) < c.size()) {
           FormatValue<dynamic>(c.at(key)).format(arg, cb);
         } else{
           FormatValue<V>(val_.defaultValue).format(arg, cb);