From: Xiubo Li Date: Wed, 23 Sep 2020 01:09:56 +0000 (+0800) Subject: client: simplify the iterating related code to make it more readable X-Git-Tag: v17.0.0~1000^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1a902c4631552f8e5e1eef1f5633e0c836c1951b;p=ceph.git client: simplify the iterating related code to make it more readable Signed-off-by: Xiubo Li --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 145a1c02e290c..8c9ceea9c600f 100755 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -335,11 +335,8 @@ Client::~Client() void Client::tear_down_cache() { // fd's - for (ceph::unordered_map::iterator it = fd_map.begin(); - it != fd_map.end(); - ++it) { - Fh *fh = it->second; - ldout(cct, 1) << __func__ << " forcing close of fh " << it->first << " ino " << fh->inode->ino << dendl; + for (auto &[fd, fh] : fd_map) { + ldout(cct, 1) << __func__ << " forcing close of fh " << fd << " ino " << fh->inode->ino << dendl; _release_fh(fh); } fd_map.clear(); diff --git a/src/client/Client.h b/src/client/Client.h index 07f37078ab9d0..1405715545efa 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -852,10 +852,10 @@ protected: * Resolve file descriptor, or return NULL. */ Fh *get_filehandle(int fd) { - ceph::unordered_map::iterator p = fd_map.find(fd); - if (p == fd_map.end()) + auto it = fd_map.find(fd); + if (it == fd_map.end()) return NULL; - return p->second; + return it->second; } // helpers