tweaks: reshuffle some lines, to avoid tallying the menus when not needed

master
Benno Schulenberg 2020-01-20 17:36:31 +01:00
parent eb1668ce81
commit 0ff9499583
1 changed files with 11 additions and 8 deletions

View File

@ -806,22 +806,25 @@ void parse_binding(char *ptr, bool dobind)
if (!dobind) if (!dobind)
goto free_things; goto free_things;
/* Tally up the menus where the function exists. */ if (is_universal(newsc->func))
for (funcstruct *f = allfuncs; f != NULL; f = f->next) mask = MMOST|MBROWSER;
if (f->func == newsc->func)
mask = mask | f->menus;
#ifndef NANO_TINY #ifndef NANO_TINY
/* Handle the special case of the toggles. */ /* Handle the special case of the toggles. */
if (newsc->func == do_toggle_void) else if (newsc->func == do_toggle_void)
mask = MMAIN; mask = MMAIN;
#endif #endif
/* Handle the special case of a key defined as a string. */ /* Handle the special case of a key defined as a string. */
if (newsc->func == (functionptrtype)implant) else if (newsc->func == (functionptrtype)implant)
mask = MMOST|MBROWSER|MHELP; mask = MMOST|MBROWSER|MHELP;
else {
/* Tally up the menus where the function exists. */
for (funcstruct *f = allfuncs; f != NULL; f = f->next)
if (f->func == newsc->func)
mask = mask | f->menus;
}
/* Now limit the given menu to those where the function exists. */ /* Now limit the given menu to those where the function exists. */
menu = menu & (is_universal(newsc->func) ? (MMOST|MBROWSER) : mask); menu = menu & mask;
if (!menu) { if (!menu) {
if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE))