From: Andy Shevchenko Date: Fri, 27 Jan 2023 15:51:35 +0000 (+0200) Subject: lib/string: Use strchr() in strpbrk() X-Git-Tag: v6.6.17~5524^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a8c55407a7230798eb157ed2cf5398a6a2b123b6;p=platform%2Fkernel%2Flinux-rpi.git lib/string: Use strchr() in strpbrk() Use strchr() instead of open coding it as it's done elsewhere in the same file. Either we will have similar to what it was or possibly better performance in case architecture implements its own strchr(). Memory wise on x86_64 bloat-o-meter shows the following Function old new delta strsep 111 102 -9 Total: Before=2763, After=2754, chg -0.33% Signed-off-by: Andy Shevchenko Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20230127155135.27153-1-andriy.shevchenko@linux.intel.com --- diff --git a/lib/string.c b/lib/string.c index 4fb566e..3d55ef8 100644 --- a/lib/string.c +++ b/lib/string.c @@ -480,13 +480,11 @@ EXPORT_SYMBOL(strcspn); */ char *strpbrk(const char *cs, const char *ct) { - const char *sc1, *sc2; + const char *sc; - for (sc1 = cs; *sc1 != '\0'; ++sc1) { - for (sc2 = ct; *sc2 != '\0'; ++sc2) { - if (*sc1 == *sc2) - return (char *)sc1; - } + for (sc = cs; *sc != '\0'; ++sc) { + if (strchr(ct, *sc)) + return (char *)sc; } return NULL; }