mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
Merge pull request #905 from robobenklein/robobenklein/defined-variable-performance-hotfix
[performance] Defined function 2-20 times speedup
This commit is contained in:
commit
a7b3f310d3
2 changed files with 2 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue