Merge pull request #905 from robobenklein/robobenklein/defined-variable-performance-hotfix

[performance] Defined function 2-20 times speedup
This commit is contained in:
Ben Hilburn
2018-07-13 13:25:45 -04:00
committed by GitHub
2 changed files with 2 additions and 4 deletions
+1 -3
View File
@@ -9,9 +9,7 @@
# Exits with 0 if a variable has been previously defined (even if empty)
# Takes the name of a variable that should be checked.
function defined() {
local varname="$1"
typeset -p "$varname" > /dev/null 2>&1
[[ ! -z "${(tP)1}" ]]
}
# Given the name of a variable and a default value, sets the variable
+1 -1
View File
@@ -498,7 +498,7 @@ prompt_battery() {
fi
fi
# return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal
if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
if defined POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD && [[ "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
return
fi