From 39ad45ce6338aa11e488e209c61153e274cfb516 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 3 Sep 2021 22:52:06 +0800 Subject: [PATCH] crimson/os: use structured binding in loop 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 --- src/crimson/os/cyanstore/cyan_store.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index cafcf8559ee..dbefe007471 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -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; } -- 2.39.5