From b489dbe65859cc9b6cc1ebced29ccc7d12a49e62 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 30 Dec 2020 17:17:56 +0800 Subject: [PATCH] client: simplify the iterating code Signed-off-by: Xiubo Li (cherry picked from commit 1bea6e5135148169baaf656563bb1acbe6a593b6) --- src/client/Client.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index b6e5a1cc3e623..06f3996791edb 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4948,18 +4948,12 @@ void Client::update_snap_trace(const bufferlist& bl, SnapRealm **realm_ret, bool put_snap_realm(realm); } - for (map::iterator q = dirty_realms.begin(); - q != dirty_realms.end(); - ++q) { - SnapRealm *realm = q->first; + for (auto &[realm, snapc] : dirty_realms) { // if there are new snaps ? - if (has_new_snaps(q->second, realm->get_snap_context())) { + if (has_new_snaps(snapc, realm->get_snap_context())) { ldout(cct, 10) << " flushing caps on " << *realm << dendl; - xlist::iterator r = realm->inodes_with_caps.begin(); - while (!r.end()) { - Inode *in = *r; - ++r; - queue_cap_snap(in, q->second); + for (auto&& in : realm->inodes_with_caps) { + queue_cap_snap(in, snapc); } } else { ldout(cct, 10) << " no new snap on " << *realm << dendl; -- 2.39.5