From c9a77bb4743f2a1a30659d5d22b7ebef43e3404a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sat, 8 Jun 2019 21:06:15 -0500 Subject: [PATCH] Optimize history search reset checking `history_search.active()` is an atomic read, whereas `command_ends_history_search(..)` is a little bit heavier. --- src/reader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index b7869ce90..ba4e5c4bd 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -3260,10 +3260,10 @@ maybe_t reader_data_t::readline(int nchars_or_0) { handle_readline_command(readline_cmd, rls); - if (command_ends_history_search(readline_cmd)) { + if (history_search.active() && command_ends_history_search(readline_cmd)) { // "cancel" means to abort the whole thing, other ending commands mean to finish the // search. - if (history_search.active() && readline_cmd == rl::cancel) { + if (readline_cmd == rl::cancel) { history_search.go_to_end(); update_command_line_from_history_search(); }