]> granicus.if.org Git - procps-ng/commitdiff
top: make rcfile duplicate fields check more efficient
authorJim Warner <james.warner@comcast.net>
Tue, 19 Jun 2018 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Tue, 26 Jun 2018 11:25:17 +0000 (21:25 +1000)
Jeeze, there was no need to employ *both* strchr() and
strrchr() when ensuring fields hadn't been duplicated.

So let's avoid one of those function calls completely.

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 3d562280a486f878dc7f722f83ae121aa4b26c21..80c2297f16a6c31b041fc33d604e158ee3f6ec16 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -3274,7 +3274,7 @@ static const char *config_file (FILE *fp, const char *name, float *delay) {
 #endif
       // ensure there's been no manual alteration of fieldscur
       for (n = 0 ; n < EU_MAXPFLGS; n++) {
-         if (strchr(w->rc.fieldscur, w->rc.fieldscur[n]) != strrchr(w->rc.fieldscur, w->rc.fieldscur[n]))
+         if (&w->rc.fieldscur[n] != strrchr(w->rc.fieldscur, w->rc.fieldscur[n]))
             return p;
       }
       // be tolerant of missing release 3.3.10 graph modes additions