diff options
author | merakor <cem@ckyln.com> | 2021-02-04 09:39:45 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-02-04 09:39:45 +0000 |
commit | 492d8cca79b1cb392aa585bce2e269f40dba070a (patch) | |
tree | ef8a1233201d55a5a52934372d54262f0ac0e5a9 /src | |
parent | 3cdb021bbe2c712b35180dfaecc31aaf07fc4d1a (diff) | |
download | cpt-492d8cca79b1cb392aa585bce2e269f40dba070a.tar.gz |
pkg_find(): break early if only a single match is requested
FossilOrigin-Name: ff26aa326167c4751040d86e06e298ac11b4ed7923b729ed3940e881bdc24124
Diffstat (limited to 'src')
-rw-r--r-- | src/cpt-lib.in | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 1bcd8bc..5690ebe 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -539,6 +539,9 @@ pkg_find() { for path2 in "$path/"$query; do test "${type:--d}" "$path2" && set -f -- "$@" "$path2" done + # Break early if we only want a single match for a slight increase + # in speed. We don't need to search for the entire path. + [ "$1" ] && [ -z "$match" ] && break done IFS=$old_ifs |