]> Sergey Matveev's repositories - nnn.git/commitdiff
Minor optimization
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 10 May 2021 11:44:21 +0000 (17:14 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 10 May 2021 11:55:24 +0000 (17:25 +0530)
src/nnn.c

index 3d7c09b69aa086192d547947c6b40f8e060a41dd..5c3e57f8650d50523d9efc9192e7f98fff1488a2 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3706,32 +3706,35 @@ static uchar_t get_color_pair_name_ind(const struct entry *ent, char *pind, int
 
 static void printent(const struct entry *ent, uint_t namecols, bool sel)
 {
+       char ind = '\0';
+       int attrs;
+
        if (cfg.showdetail) {
-               int attrs = g_state.oldcolor ? (resetdircolor(ent->flags), A_DIM)
-                                                       : (fcolors[C_MIS] ? COLOR_PAIR(C_MIS) : 0);
-               int entry_type = ent->mode & S_IFMT;
+               int type = ent->mode & S_IFMT;
                char perms[6] = {' ', ' ', (char)('0' + ((ent->mode >> 6) & 7)),
-                               (char)('0' + ((ent->mode >> 3) & 7)), (char)('0' + (ent->mode & 7)), '\0'};
-               char ind[2] = {'\0'};
+                               (char)('0' + ((ent->mode >> 3) & 7)),
+                               (char)('0' + (ent->mode & 7)), '\0'};
 
                addch(sel ? ' ' | A_REVERSE : ' '); /* Reversed block for hovered entry */
 
+               attrs = g_state.oldcolor ? (resetdircolor(ent->flags), A_DIM)
+                                        : (fcolors[C_MIS] ? COLOR_PAIR(C_MIS) : 0);
                if (attrs)
                        attron(attrs);
 
                /* Print details */
                print_time(&ent->sec);
 
-               printw("%s%9s ", perms, (entry_type == S_IFREG || entry_type == S_IFDIR)
+               printw("%s%9s ", perms, (type == S_IFREG || type == S_IFDIR)
                        ? coolsize(cfg.blkorder ? (blkcnt_t)ent->blocks << blk_shift : ent->size)
-                       : (ind[0] = get_detail_ind(ent->mode), ind));
+                       : (type = (uchar_t)get_detail_ind(ent->mode), (char *)&type));
 
                if (attrs)
                        attroff(attrs);
        }
 
-       char ind = '\0';
-       int attrs = 0;
+       attrs = 0;
+
        uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
 
        addch((ent->flags & FILE_SELECTED) ? '+' | A_REVERSE : ' ');