public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] getenv: Move call to strlen to the branch it's used in.
@ 2020-12-18  6:33 Siddhesh Poyarekar
  0 siblings, 0 replies; only message in thread
From: Siddhesh Poyarekar @ 2020-12-18  6:33 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=59d572ef613252281e31f867099c43f098319ad7

commit 59d572ef613252281e31f867099c43f098319ad7
Author: Lode Willems <Lode.Willems@UGent.be>
Date:   Fri Dec 18 12:02:27 2020 +0530

    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  <Lode.Willems@UGent.be>
    
            * tdlib/getenv.c: Move the call to strlen into the branch it's used.

Diff:
---
 stdlib/getenv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stdlib/getenv.c b/stdlib/getenv.c
index 57a8b6f013..b38b332ff8 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-18  6:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18  6:33 [glibc] getenv: Move call to strlen to the branch it's used in Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).