summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-04-27 08:59:12 -0400
committerSven Eden <yamakuzure@gmx.net>2017-06-16 10:12:58 +0200
commit792902f968872bb5dd8639bc7c6bbfc7831817f5 (patch)
tree864b463fd206e627f216ce38225ddcc970747e50 /src
parent6b05aab633fa55aa3070f186869d8fa219be2f38 (diff)
basic/dirent-util: do not call hidden_file_allow_backup from dirent_is_file_with_suffix
If the file name is supposed to end in a suffix, there's not need to check the name against a list of "special" file names, which is slow. Instead, just check that the name doens't start with a period.
Diffstat (limited to 'src')
-rw-r--r--src/basic/dirent-util.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/basic/dirent-util.c b/src/basic/dirent-util.c
index 5fb535cb1..5019882a0 100644
--- a/src/basic/dirent-util.c
+++ b/src/basic/dirent-util.c
@@ -55,9 +55,7 @@ bool dirent_is_file(const struct dirent *de) {
if (hidden_file(de->d_name))
return false;
- if (de->d_type != DT_REG &&
- de->d_type != DT_LNK &&
- de->d_type != DT_UNKNOWN)
+ if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
return false;
return true;
@@ -66,12 +64,10 @@ bool dirent_is_file(const struct dirent *de) {
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
assert(de);
- if (de->d_type != DT_REG &&
- de->d_type != DT_LNK &&
- de->d_type != DT_UNKNOWN)
+ if (!IN_SET(de->d_type, DT_REG, DT_LNK, DT_UNKNOWN))
return false;
- if (hidden_file_allow_backup(de->d_name))
+ if (de->d_name[0] == '.')
return false;
return endswith(de->d_name, suffix);