]> granicus.if.org Git - procps-ng/commit
top: trade that 'strncpy' for more efficient 'memccpy'
authorJim Warner <james.warner@comcast.net>
Mon, 14 Feb 2022 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@dropbear.xyz>
Thu, 17 Feb 2022 07:23:30 +0000 (18:23 +1100)
commit98ca9fe3676fbc479a02005fe45b0cb019e277d7
tree7c37b596025aa8e92ed497cec84f5474c9a51e25
parent787615d8da696a6fa9bf47ec99652e7256a20239
top: trade that 'strncpy' for more efficient 'memccpy'

This patch was prompted by the merge request for pgrep
referenced below. In top's case, any performance gains
will be minimal since the now defunct strncpy was only
employed for termcap rebuilds after interacting with a
user (+ 1 other non-termcap related user interaction).

[ golly, strncpy always calls at least two functions ]
[ but usually calls a total of 3. on the other hand, ]
[ memccpy will only call a maximum of two functions. ]

And thanks to Baruch Siach for these strncpy insights.

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/148

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