Cache the results of is_exe_in_path.
Review Request #11823 — Created Sept. 27, 2021 and submitted
is_exe_in_path()may be called multiple times with the same executable
name, particularly when running from unit tests. Since an executable is
unlikely to appear or disappear within the lifetime of a process run in
a way that impacts RBTools, it's not worth re-scanning the whole path
every time we need to know if an executable is available.
This change adds caching behavior to
is_exe_in_path(). Now, a repeated
call with the same executable name (with or without a
extension) will return the prior cached result.
All unit tests pass.
Might be a little simpler as: if name not in _exe_in_path_cache: ... _exe_in_path_cache[name] = found return _exe_in_path_cache[name]