Add lookup caching and absolute path checking to is_exe_in_path().

Review Request #11526 — Created March 15, 2021 and submitted

Information

ReviewBot
release-3.0.x

Reviewers

Every time we call is_exe_in_path(), it must re-scan the $PATH.
It's not a big performance issue, but we do look up some of the same
binaries more than once.

This change addresses this by allowing is_exe_in_path() to take a
cache parameter, which is a dictionary matching names to found paths
(or None, if not found). It also prevents a lookup if the path
provided is an absolute path.

Really, though, this is laying some groundwork for some improved
dependency checking, where the cache will be reused for looking up
binary files at both dependency resolution and process execution time.

Unit tests passed.

Made use of this in the upcoming dependency change.

Summary ID
Add lookup caching and absolute path checking to is_exe_in_path().
Every time we call `is_exe_in_path()`, it must re-scan the `$PATH`. It's not a big performance issue, but we do look up some of the same binaries more than once. This change addresses this by allowing `is_exe_in_path()` to take a `cache` parameter, which is a dictionary matching names to found paths (or `None`, if not found). It also prevents a lookup if the path provided is an absolute path. Really, though, this is laying some groundwork for some improved dependency checking, where the cache will be reused for looking up binary files at both dependency resolution and process execution time.
d9e84bff38ceb629b51502913aa4c74a83a3b1da
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (438fb7d)