From 492d8cca79b1cb392aa585bce2e269f40dba070a Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 4 Feb 2021 09:39:45 +0000 Subject: pkg_find(): break early if only a single match is requested FossilOrigin-Name: ff26aa326167c4751040d86e06e298ac11b4ed7923b729ed3940e881bdc24124 --- src/cpt-lib.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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 -- cgit v1.2.3