]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: simplify the iterating related code to make it more readable
authorXiubo Li <xiubli@redhat.com>
Wed, 23 Sep 2020 01:09:56 +0000 (09:09 +0800)
committerXiubo Li <xiubli@redhat.com>
Fri, 25 Sep 2020 00:46:03 +0000 (08:46 +0800)
Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/client/Client.cc
src/client/Client.h

index 145a1c02e290c44af146f682be7e7ff3eb7eabd1..8c9ceea9c600f933e14b3eb94d9d13df33f457f4 100755 (executable)
@@ -335,11 +335,8 @@ Client::~Client()
 void Client::tear_down_cache()
 {
   // fd's
-  for (ceph::unordered_map<int, Fh*>::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();
index 07f37078ab9d0100521bb2d2b07e12bf09ab9766..1405715545efa9eeaeb407588923cef3f22604ee 100644 (file)
@@ -852,10 +852,10 @@ protected:
    * Resolve file descriptor, or return NULL.
    */
   Fh *get_filehandle(int fd) {
-    ceph::unordered_map<int, Fh*>::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