summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-06-23 22:24:54 -0700
committerOri Bernstein <ori@eigenstate.org>2018-06-23 22:24:54 -0700
commitc8397e67b2c1f2a994c4399e0654fe145b97629a (patch)
treeb28e77c1e0dea3019e426fed5e9f12fa9f02f8a9 /lib
parent974475bcfe52a488d9f5e83e474b6ca3670d5f6a (diff)
downloadmc-c8397e67b2c1f2a994c4399e0654fe145b97629a.tar.gz
Initialize the env eagerly.
This prevents potential allocations when getting the PATH environment variable.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/env+posixy.myr7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/std/env+posixy.myr b/lib/std/env+posixy.myr
index cf4d8f7..82ad4ff 100644
--- a/lib/std/env+posixy.myr
+++ b/lib/std/env+posixy.myr
@@ -25,10 +25,13 @@ const Zenvp = (0 : byte#)
var envduped : bool = false
var environ : byte#[:]
+const __init__ = {
+ envinit()
+}
+
const getenv = {name
var n, env
- envinit()
for envp : environ
if envp != Zenvp
env = cstrconvp(envp)
@@ -51,8 +54,6 @@ const getenvv = {name, default
const setenv = {name, val
var n, e, env, idx, found
- envinit()
-
idx = 0
found = false
e = fmt("{}={}\0", name, val)