From 9a5a155e75f4d7a7ebd691aafaee13c71035252a Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 22 Aug 2021 00:00:00 -0500 Subject: [PATCH] library: trade 2 strstr & atoi calls for 1 sscanf call Signed-off-by: Jim Warner --- proc/readproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/proc/readproc.c b/proc/readproc.c index fc66d0cf..6c986266 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -1077,11 +1077,8 @@ static void autogroup_fill (const char *path, proc_t *p) { close(fd); if (in > 0) { buf[in] = '\0'; - if ((str = strstr(buf, "-"))) - p->autogrp_id = atoi(++str); - if ((str = strstr(buf, "nice"))) - p->autogrp_nice = atoi(str + sizeof("nice")); - // above sizeof includes null, skips space ahead of # + sscanf(buf, "/autogroup-%d nice %d" + , &p->autogrp_id, &p->autogrp_nice); } } }