aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-01-08 19:08:01 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-01-08 19:08:01 +0530
commitd209e8f278e434b707ea861ec3988c4b491ee7b2 (patch)
tree4b25214a53830e1fe84c41676a397800cc9794c5
parent0b1c87758c116536f8515b8d9244c7763272a01f (diff)
downloadnnn-d209e8f278e434b707ea861ec3988c4b491ee7b2.tar.gz
Optimize file extension check
-rw-r--r--src/nnn.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 0e70fbf..2d0ca54 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1865,8 +1865,8 @@ static int entrycmp(const void *va, const void *vb)
if (pb->blocks < pa->blocks)
return -1;
} else if (cfg.extnorder && !(pb->flags & DIR_OR_LINK_TO_DIR)) {
- char *extna = xmemrchr((uchar *)pa->name, '.', strlen(pa->name));
- char *extnb = xmemrchr((uchar *)pb->name, '.', strlen(pb->name));
+ char *extna = xmemrchr((uchar *)pa->name, '.', pa->nlen - 1);
+ char *extnb = xmemrchr((uchar *)pb->name, '.', pb->nlen - 1);
if (extna || extnb) {
if (!extna)
@@ -4215,7 +4215,7 @@ static void redraw(char *path)
/* Get the file extension for regular files */
if (S_ISREG(pent->mode)) {
- i = (int)strlen(pent->name);
+ i = (int)(pent->nlen - 1);
ptr = xmemrchr((uchar *)pent->name, '.', i);
if (ptr)
attrs = ptr - pent->name; /* attrs used as tmp var */