From 1a902c4631552f8e5e1eef1f5633e0c836c1951b Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 23 Sep 2020 09:09:56 +0800 Subject: [PATCH] client: simplify the iterating related code to make it more readable Signed-off-by: Xiubo Li --- src/client/Client.cc | 7 ++----- src/client/Client.h | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) 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 -- 2.39.5