mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Optimize file extension check
This commit is contained in:
parent
0b1c87758c
commit
d209e8f278
|
@ -1865,8 +1865,8 @@ static int entrycmp(const void *va, const void *vb)
|
||||||
if (pb->blocks < pa->blocks)
|
if (pb->blocks < pa->blocks)
|
||||||
return -1;
|
return -1;
|
||||||
} else if (cfg.extnorder && !(pb->flags & DIR_OR_LINK_TO_DIR)) {
|
} else if (cfg.extnorder && !(pb->flags & DIR_OR_LINK_TO_DIR)) {
|
||||||
char *extna = xmemrchr((uchar *)pa->name, '.', strlen(pa->name));
|
char *extna = xmemrchr((uchar *)pa->name, '.', pa->nlen - 1);
|
||||||
char *extnb = xmemrchr((uchar *)pb->name, '.', strlen(pb->name));
|
char *extnb = xmemrchr((uchar *)pb->name, '.', pb->nlen - 1);
|
||||||
|
|
||||||
if (extna || extnb) {
|
if (extna || extnb) {
|
||||||
if (!extna)
|
if (!extna)
|
||||||
|
@ -4215,7 +4215,7 @@ static void redraw(char *path)
|
||||||
|
|
||||||
/* Get the file extension for regular files */
|
/* Get the file extension for regular files */
|
||||||
if (S_ISREG(pent->mode)) {
|
if (S_ISREG(pent->mode)) {
|
||||||
i = (int)strlen(pent->name);
|
i = (int)(pent->nlen - 1);
|
||||||
ptr = xmemrchr((uchar *)pent->name, '.', i);
|
ptr = xmemrchr((uchar *)pent->name, '.', i);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
attrs = ptr - pent->name; /* attrs used as tmp var */
|
attrs = ptr - pent->name; /* attrs used as tmp var */
|
||||||
|
|
Loading…
Reference in a new issue