aboutsummaryrefslogtreecommitdiffstats
path: root/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-03-19 03:54:19 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-03-19 03:54:19 +0530
commit5624905803c0e64a0e2fa9caf433649eb6323e52 (patch)
treef713037d28cc3e83940bcf0d3fc25eb9f41fced3 /nnn.c
parentdbf60734ba3d540a017081cebcfef901498c0aea (diff)
downloadnnn-5624905803c0e64a0e2fa9caf433649eb6323e52.tar.gz
Omit sorting if no matches/entries
Diffstat (limited to 'nnn.c')
-rw-r--r--nnn.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/nnn.c b/nnn.c
index 402ee58..588d582 100644
--- a/nnn.c
+++ b/nnn.c
@@ -1050,7 +1050,7 @@ nextsel(char **run, char **env, int *presel)
/*
* Move non-matching entries to the end
*/
-static void
+static int
fill(struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re)
{
static int count;
@@ -1071,6 +1071,8 @@ fill(struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re)
continue;
}
}
+
+ return ndents;
}
static int
@@ -1082,8 +1084,10 @@ matches(char *fltr)
if (setfilter(&re, fltr) != 0)
return -1;
- fill(&dents, visible, &re);
+ ndents = fill(&dents, visible, &re);
regfree(&re);
+ if (ndents == 0)
+ return 0;
qsort(dents, ndents, sizeof(*dents), entrycmp);
@@ -2224,6 +2228,8 @@ populate(char *path, char *oldname, char *fltr)
ndents = dentfill(path, &dents, visible, &re);
regfree(&re);
+ if (ndents == 0)
+ return 0;
qsort(dents, ndents, sizeof(*dents), entrycmp);