]> granicus.if.org Git - graphviz/commitdiff
remove getenv("PATH") caching
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Apr 2021 00:02:25 +0000 (17:02 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Apr 2021 22:24:06 +0000 (15:24 -0700)
On most modern platforms, getenv is accessing a static array in the address
space. So this caching does not add any benefit.

lib/ast/pathbin.c

index f06bb704252d3b1607687c125f627ceaa2cbfb41..5e2cefac8bd99a1d0af72972f16b8e2d26fd6a43 100644 (file)
@@ -21,11 +21,8 @@ char *pathbin(void)
 {
     char *bin;
 
-    static char *val;
-
-    if ((!(bin = getenv("PATH")) || !*bin) && !(bin = val)) {
+    if (!(bin = getenv("PATH")) || !*bin) {
        bin = "/bin:/usr/bin:/usr/local/bin";
-       val = bin;
     }
     return bin;
 }