]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os: use structured binding in loop 43043/head
authorKefu Chai <tchaikov@gmail.com>
Fri, 3 Sep 2021 14:52:06 +0000 (22:52 +0800)
committerKefu Chai <tchaikov@gmail.com>
Fri, 3 Sep 2021 14:52:12 +0000 (22:52 +0800)
also avoid using `map[key] = val` for setting an item in map, as, if
he key does not exist in map, `map[key]` would have to create a value
using its default ctor, and then call the `operator=(bufferlist&&)` to
set it.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/crimson/os/cyanstore/cyan_store.cc

index cafcf8559ee1f6abe00e4de21a858e8a6480a969..dbefe007471bb1476ad0da130804cf9315e47438 100644 (file)
@@ -692,8 +692,9 @@ int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid,
   ObjectRef o = c->get_object(oid);
   if (!o)
     return -ENOENT;
-  for (auto p = aset.begin(); p != aset.end(); ++p)
-    o->xattr[p->first] = p->second;
+  for (auto&& [key, val]: aset) {
+    o->xattr.insert_or_assign(std::move(key), std::move(val));
+  }
   return 0;
 }