Reset autoloads in response to variable changes

Prior to this fix, autoloads like function and completion autoloads
would check their path variable (like fish_function_path) on every
autoload request. Switch to invalidating it in response to the variable
changing.

This improves time on a microbenchmark:

    for i in (seq 50000)
      setenv test_env val$i
    end

from ~11 seconds to ~6.5 seconds.
This commit is contained in:
ridiculousfish
2018-02-15 21:58:02 -08:00
parent be13ac353b
commit 9cd952588f
7 changed files with 44 additions and 19 deletions

View File

@@ -339,6 +339,8 @@ int function_get_definition_lineno(const wcstring &name) {
return 1 + std::count(source.begin(), source.begin() + func_start, L'\n');
}
void function_invalidate_path() { function_autoloader.invalidate(); }
// Setup the environment for the function. There are three components of the environment:
// 1. argv
// 2. named arguments