diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-05-29 16:44:50 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-06-01 12:14:24 +0100 |
commit | 39d1c9576a3f2e5e65c5fb06744aa7245d743bc0 (patch) | |
tree | ea1683d5396339976ee9eb60c502d677d0f3a573 | |
parent | 25a2c948b24163ce0e0e9e52f6a5fef33d7d7842 (diff) | |
download | coreutils-39d1c9576a3f2e5e65c5fb06744aa7245d743bc0.tar.xz |
stat: avoid redundant stat() calls
* src/stat.c (find_bind_mount): NAME is invariant in the loop,
so only stat(NAME) outside the loop.
-rw-r--r-- | src/stat.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/stat.c b/src/stat.c index 6f42b61bd..0f67d22df 100644 --- a/src/stat.c +++ b/src/stat.c @@ -841,17 +841,19 @@ find_bind_mount (char const * name) tried_mount_list = true; } + struct stat name_stats; + if (stat (name, &name_stats) != 0) + return NULL; + struct mount_entry *me; for (me = mount_list; me; me = me->me_next) { if (me->me_dummy && me->me_devname[0] == '/' && STREQ (me->me_mountdir, name)) { - struct stat name_stats; struct stat dev_stats; - if (stat (name, &name_stats) == 0 - && stat (me->me_devname, &dev_stats) == 0 + if (stat (me->me_devname, &dev_stats) == 0 && SAME_INODE (name_stats, dev_stats)) { bind_mount = me->me_devname; |