From 73bf9dd784f7c35853312eea9f2ec3bf133c9513 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 12 Jul 2020 18:31:45 -0500 Subject: [PATCH] Stop calling path_get_path for builtins and functions highlight.cpp was blindly calling path_get_path for each head command typed at the prompt which triggers a lot of syscalls via waccess. It's still going to do that while commands are being composed, but now it won't if we can make a cheap lookup to the builtins/functions hash table and can determine that it's a valid command before inspecting the filesystem. --- src/highlight.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/highlight.cpp b/src/highlight.cpp index abb68d2e7..0312baac4 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -453,12 +453,9 @@ bool autosuggest_validate_from_history(const history_item_t &item, } // Not handled specially so handle it here. - bool cmd_ok = false; - if (path_get_path(parsed_command, nullptr, ctx.vars)) { - cmd_ok = true; - } else if (builtin_exists(parsed_command) || function_exists_no_autoload(parsed_command)) { - cmd_ok = true; - } + bool cmd_ok = builtin_exists(parsed_command) + || function_exists_no_autoload(parsed_command) + || path_get_path(parsed_command, nullptr, ctx.vars); if (cmd_ok) { const path_list_t &paths = item.get_required_paths();