]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: cache the result of checking whether "XMODE" column is enabled or not
authorMasatake YAMATO <yamato@redhat.com>
Thu, 27 Jul 2023 16:35:00 +0000 (01:35 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 11 Sep 2023 11:09:09 +0000 (20:09 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c

index bb513c07e1d7ca560e189bda5869d60ba19d5ad2..fb52c86244b0040a8abdf9c0461f1fdae51a803b 100644 (file)
@@ -478,7 +478,8 @@ struct lsfd_control {
                        threads : 1,
                        show_main : 1,          /* print main table */
                        show_summary : 1,       /* print summary/counters */
-                       sockets_only : 1;       /* display only SOCKETS */
+                       sockets_only : 1,       /* display only SOCKETS */
+                       show_xmode : 1;         /* XMODE column is enabled. */
 
        struct lsfd_filter *filter;
        struct lsfd_counter **counters;         /* NULL terminated array. */
@@ -2118,6 +2119,9 @@ int main(int argc, char *argv[])
        if (n_pids > 0)
                sort_pids(pids, n_pids);
 
+       if (scols_table_get_column_by_name(ctl.tb, "XMODE"))
+               ctl.show_xmode = 1;
+
        /* collect data */
        initialize_nodevs();
        initialize_classes();
@@ -2128,7 +2132,7 @@ int main(int argc, char *argv[])
        free(pids);
 
        attach_xinfos(&ctl.procs);
-       if (scols_table_get_column_by_name(ctl.tb, "XMODE"))
+       if (ctl.show_xmode)
                set_multiplexed_flags(&ctl.procs);