commit 7fa6e95ce123301c7e24c8c7baa09212c5a227ba
parent 8bce70e03895aea164958acbb8269dbefe7b0d90
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 26 Jun 2020 19:44:19 +0200
tweaks: avoid a function call when a simple boolean will do
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/prompt.c b/src/prompt.c
@@ -415,8 +415,8 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
char *magichistory = NULL;
/* The (partial) answer that was typed at the prompt, if any. */
#ifdef ENABLE_TABCOMP
- int last_kbinput = ERR;
- /* The key we pressed before the current key. */
+ bool previous_was_tab = FALSE;
+ /* Whether the previous keystroke was an attempt at tab completion. */
size_t fragment_length = 0;
/* The length of the fragment that the user tries to tab complete. */
#endif
@@ -451,7 +451,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
if (func == do_tab) {
#ifdef ENABLE_HISTORIES
if (history_list != NULL) {
- if (last_kbinput != the_code_for(do_tab, '\t'))
+ if (!previous_was_tab)
fragment_length = strlen(answer);
if (fragment_length > 0) {
@@ -523,7 +523,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
break;
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
- last_kbinput = kbinput;
+ previous_was_tab = (func == do_tab);
#endif
}