tweaks: avoid a function call when a simple boolean will do

master
Benno Schulenberg 2020-06-26 19:44:19 +02:00
parent 8bce70e038
commit 7fa6e95ce1
1 changed files with 4 additions and 4 deletions

View File

@ -415,8 +415,8 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
char *magichistory = NULL; char *magichistory = NULL;
/* The (partial) answer that was typed at the prompt, if any. */ /* The (partial) answer that was typed at the prompt, if any. */
#ifdef ENABLE_TABCOMP #ifdef ENABLE_TABCOMP
int last_kbinput = ERR; bool previous_was_tab = FALSE;
/* The key we pressed before the current key. */ /* Whether the previous keystroke was an attempt at tab completion. */
size_t fragment_length = 0; size_t fragment_length = 0;
/* The length of the fragment that the user tries to tab complete. */ /* The length of the fragment that the user tries to tab complete. */
#endif #endif
@ -451,7 +451,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
if (func == do_tab) { if (func == do_tab) {
#ifdef ENABLE_HISTORIES #ifdef ENABLE_HISTORIES
if (history_list != NULL) { if (history_list != NULL) {
if (last_kbinput != the_code_for(do_tab, '\t')) if (!previous_was_tab)
fragment_length = strlen(answer); fragment_length = strlen(answer);
if (fragment_length > 0) { if (fragment_length > 0) {
@ -523,7 +523,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
break; break;
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP) #if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput; previous_was_tab = (func == do_tab);
#endif #endif
} }