diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2016-02-11 14:57:24 +0100 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2016-02-13 17:08:19 +0100 |
commit | 585bdf45c8abf6c837ca1e0dd70f8c54beb1833d (patch) | |
tree | 48c524e4493c4b700feb7a5852639c4f3cc6cf4b /share/functions/abbr.fish | |
parent | 89206d865419135593e66567fa2186034869d766 (diff) |
abbr: Bail early when the abbr already exists
This speeds up the common case of `abbr -a` calls in config.fish by
about 90% - from 900ms to 90ms for 100 calls.
Diffstat (limited to 'share/functions/abbr.fish')
-rw-r--r-- | share/functions/abbr.fish | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish index e86ea559..b37091c4 100644 --- a/share/functions/abbr.fish +++ b/share/functions/abbr.fish @@ -72,6 +72,9 @@ function abbr --description "Manage abbreviations" switch $mode case 'add' + # Bail out early if the exact abbr is already in + # This depends on the separator staying the same, but that's the common case (config.fish) + contains -- $mode_arg $fish_user_abbreviations; and return 0 set -l key set -l value __fish_abbr_parse_entry $mode_arg key value |