clipmenu

Simple clipboard management using dmenu
git clone https://git.sinitax.com/cdown/clipmenu
Log | Files | Refs | README | LICENSE | sfeed.txt

commit f0fe96955af9bb0bacea06b93752fe51c72d3024
parent e8ba60e43228311b6da89245c49944405ae36a86
Author: Chris Down <chris@chrisdown.name>
Date:   Fri,  6 Jan 2017 12:52:34 +0000

perf: Don't use printf with ordered_selections

printf is really, really slow with large arrays of strings. Switching to
this results in about a 50% performance improvement.

Diffstat:
Mclipmenu | 4+---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/clipmenu b/clipmenu @@ -6,13 +6,11 @@ shopt -s nullglob LC_COLLATE=C declare -A selections -ordered_selections=() cache_file=/tmp/clipmenu.$USER/line_cache # We use tac since we want newest to oldest, and we append in clipmenud while IFS='|' read -r full_file first_line; do - ordered_selections+=("$first_line") selections[$first_line]=$full_file done < <(tac "$cache_file") @@ -20,7 +18,7 @@ done < <(tac "$cache_file") # whether `-l` is also in "$@", because the way that dmenu works allows a later # argument to override an earlier one. That is, if the user passes in `-l`, our # one will be ignored. -chosen_line=$(printf '%s\n' "${ordered_selections[@]}" | uniq | dmenu -l 8 "$@") +chosen_line=$(sed 's/^[^|]\+|//' "$cache_file" | tac | uniq | dmenu -l 8 "$@") [[ $chosen_line ]] || exit 1