summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2023-10-14 17:48:37 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2023-10-14 17:55:32 +0100
commit1760deea68f4a915a502c5602c82c7f9f8404a51 (patch)
tree0e12f66f188e06dfd00d1630633db8350e9b06a8
parent0cb3f74b650550f5d8515ae5b6490663c918cbe1 (diff)
add_checked_modules_from_symbol: avoid double-lookup
By using add_checked_modules() we get an extra lookup. On modern systems this isn't notable, but for low-end or devices with spinning disks this is rather notable. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--functions11
1 files changed, 9 insertions, 2 deletions
diff --git a/functions b/functions
index 8b1f1be..cb29aa4 100644
--- a/functions
+++ b/functions
@@ -1100,9 +1100,16 @@ add_all_modules_from_symbol() {
add_checked_modules_from_symbol() {
local -a mods
- mapfile -t mods < <(find_module_from_symbol "$@")
+ # _autodetect_cache is declared in mkinitcpio and assigned in install/autodetect
+ # shellcheck disable=SC2154
+ if (( ${#_autodetect_cache[*]} )); then
+ mapfile -t mods < <(find_module_from_symbol "$@" | grep -xFf <(printf '%s\n' "${!_autodetect_cache[@]}"))
+ else
+ mapfile -t mods < <(find_module_from_symbol "$@")
+ fi
+
(( ${#mods[*]} )) || return 1
- map add_checked_modules "${mods[@]}" || :
+ map add_module "${mods[@]}"
}
# vim: set ft=sh ts=4 sw=4 et: