Browse Source

Omit sorting if no matches/entries

master
Arun Prakash Jana 6 years ago
parent
commit
5624905803
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      nnn.c

+ 8
- 2
nnn.c View File

@@ -1050,7 +1050,7 @@ nextsel(char **run, char **env, int *presel)
/* /*
* Move non-matching entries to the end * Move non-matching entries to the end
*/ */
static void
static int
fill(struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re) fill(struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re)
{ {
static int count; static int count;
@@ -1071,6 +1071,8 @@ fill(struct entry **dents, int (*filter)(regex_t *, char *), regex_t *re)
continue; continue;
} }
} }

return ndents;
} }


static int static int
@@ -1082,8 +1084,10 @@ matches(char *fltr)
if (setfilter(&re, fltr) != 0) if (setfilter(&re, fltr) != 0)
return -1; return -1;


fill(&dents, visible, &re);
ndents = fill(&dents, visible, &re);
regfree(&re); regfree(&re);
if (ndents == 0)
return 0;


qsort(dents, ndents, sizeof(*dents), entrycmp); qsort(dents, ndents, sizeof(*dents), entrycmp);


@@ -2224,6 +2228,8 @@ populate(char *path, char *oldname, char *fltr)


ndents = dentfill(path, &dents, visible, &re); ndents = dentfill(path, &dents, visible, &re);
regfree(&re); regfree(&re);
if (ndents == 0)
return 0;


qsort(dents, ndents, sizeof(*dents), entrycmp); qsort(dents, ndents, sizeof(*dents), entrycmp);




Loading…
Cancel
Save