Closed dimo414 closed 3 years ago
Wow! Playing with a bit locally timing my prompt and its looking like ~2x faster. @dimo414 thank you for this change :pray: :tada: Much appreciated!
Nice! That's even better than I expected. Thanks for the quick review!
This change allows us to avoid unnecessary command substitutions which are (relatively speaking) quite expensive. Although
__bp_sanitize_string
is only used during installation__bp_trim_whitespace
is invoked in a loop in the critical path as part of__bp_preexec_invoke_exec
. Eliminating these subshells will reduce bash-preexec's overhead.See https://github.com/dimo414/prompt.gem/commit/9764cdb3 for another example of a similar change.
Note: the
printf -v
syntax was added to Bash in v3.1: https://mywiki.wooledge.org/BashFAQ/061