55575b88f9e47d88fab02c26fc69e4af48af1cd9
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
lib: optimize default and env_default
Diff
1diff --git a/lib/functions.zsh b/lib/functions.zsh
2index 4ef8920f60ef6017ffe3dcb6ed4b90db675f9dbb..9f8736bd7e2967321fd95b561a5480f5c5d42e5e 100644
3--- a/lib/functions.zsh
4+++ b/lib/functions.zsh
5@@ -79,7 +79,7 @@ function try_alias_value() {
6 # 0 if the variable exists, 3 if it was set
7 #
8 function default() {
9- test `typeset +m "$1"` && return 0
10+ (( $+parameters[$1] )) && return 0
11 typeset -g "$1"="$2" && return 3
12 }
13
14@@ -93,8 +93,8 @@ function default() {
15 # 0 if the env variable exists, 3 if it was set
16 #
17 function env_default() {
18- env | grep -q "^$1=" && return 0
19- export "$1=$2" && return 3
20+ (( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0
21+ export "$1=$2" && return 3
22 }
23
24