]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
getenv: Move call to strlen to the branch it's used in.
authorLode Willems <Lode.Willems@UGent.be>
Fri, 18 Dec 2020 06:32:27 +0000 (12:02 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Fri, 18 Dec 2020 06:32:28 +0000 (12:02 +0530)
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  <Lode.Willems@UGent.be>

* tdlib/getenv.c: Move the call to strlen into the branch it's used.

stdlib/getenv.c

index 57a8b6f0138d0d45bcfaaf1b3d89f6213aef24ba..b38b332ff8687d8beb7db01109578258b68e4173 100644 (file)
@@ -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