From: Lode Willems Date: Fri, 18 Dec 2020 06:32:27 +0000 (+0530) Subject: getenv: Move call to strlen to the branch it's used in. X-Git-Tag: glibc-2.33~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59d572ef613252281e31f867099c43f098319ad7;p=thirdparty%2Fglibc.git getenv: Move call to strlen to the branch it's used in. The len variable is only used in the else branch. We don't need the call to strlen if the name is 0 or 1 characters long. 2019-10-02 Lode Willems * tdlib/getenv.c: Move the call to strlen into the branch it's used. --- diff --git a/stdlib/getenv.c b/stdlib/getenv.c index 57a8b6f0138..b38b332ff86 100644 --- a/stdlib/getenv.c +++ b/stdlib/getenv.c @@ -32,7 +32,6 @@ char * getenv (const char *name) { - size_t len = strlen (name); char **ep; uint16_t name_start; @@ -63,6 +62,7 @@ getenv (const char *name) } else { + size_t len = strlen (name); #if _STRING_ARCH_unaligned name_start = *(const uint16_t *) name; #else