Skip to content

Commit

Permalink
Use array reversal instead of array sorting.
Browse files Browse the repository at this point in the history
There's no need to do a full numerical sort here, since we know the
keys will be in reverse numerical order, because (R) searches in last-
to-first order. Not a big deal, but this is just simpler and
presumably more efficient.

Also cleaned up a rather confusing comment about (on) being used to
remove duplicates, which it definitely doesn't.
  • Loading branch information
parkercoates committed Mar 16, 2015
1 parent 3c7b079 commit fd31074
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions zsh-history-substring-search.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ function _history-substring-search-begin() {
#
# Find all occurrences of the search query in the history file.
#
# (k) turns it an array of line numbers.
# (k) returns the "keys" (history index numbers) instead of the values
# (Oa) reverses the order, because (R) returns results reversed.
#
# (on) seems to remove duplicates, which are default
# options. They can be turned off by (ON).
#
_history_substring_search_matches=(${(kon)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})
_history_substring_search_matches=(${(kOa)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]})

#
# Define the range of values that $_history_substring_search_match_index
Expand Down

0 comments on commit fd31074

Please sign in to comment.