Steve mentioned that strlen is appearing a little too high in profiling, so this removes one redundant use from what is probably a hot code path.
I will do the same to the else block next. >From 51eaaa809ac94ec20ddcbe62c651735106128a31 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Mon, 20 Apr 2009 08:08:42 +0200 Subject: [PATCH] logsys.c: avoid an unnecessary strlen call * exec/logsys.c (strcpy_cutoff): Use strlen, then memcpy, not strcpy, then strlen. --- exec/logsys.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exec/logsys.c b/exec/logsys.c index 1b83fa7..ca2e6bb 100644 --- a/exec/logsys.c +++ b/exec/logsys.c @@ -272,12 +272,12 @@ do { \ */ static inline int strcpy_cutoff (char *dest, const char *src, int cutoff) { - unsigned int len; - if (cutoff == -1) { - strcpy (dest, src); - return (strlen (dest)); + size_t len = strlen (src); + memcpy (dest, src, len + 1); + return (len); } else { + size_t len; assert (cutoff > 0); strncpy (dest, src, cutoff); dest[cutoff] = '\0'; -- 1.6.3.rc0.230.g3edd6 _______________________________________________ Openais mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/openais
