summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-31 18:59:45 +0100
committerThomas Bächler <thomas@archlinux.org>2011-01-31 21:48:57 +0100
commit827f4bf67eafc5a15aaa69cdb465497f4e0f954f (patch)
tree76c9a24a8bf289762b0eaa4885cdcd6ef6e1d89e
parent65cf7985377d9c63658a7a24bb853ec2d84c2e42 (diff)
downloadmkinitcpio-827f4bf67eafc5a15aaa69cdb465497f4e0f954f.tar.gz
mkinitcpio-827f4bf67eafc5a15aaa69cdb465497f4e0f954f.tar.xz
Keep an array of added modules to prevent expensive lookups
This saves a find and grep call for every module that is added more than once, which can lead to significant savings in image generation time. Generating a fallback image went from 80 seconds to 60 seconds after this patch. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--functions13
1 files changed, 8 insertions, 5 deletions
diff --git a/functions b/functions
index bd0a2c6..4cd3136 100644
--- a/functions
+++ b/functions
@@ -178,6 +178,7 @@ add_file ()
}
HAS_MODULES="n"
+declare -a ADDED_MODULES
#modules are handled specially in order to enable autodetection
add_module ()
{
@@ -186,13 +187,14 @@ add_module ()
#find pattern - replace _ with [-_] to match either
fil="${m//_/[-_]}"
+ #skip expensive stuff if this module has already been added
+ if in_array $m ${ADDED_MODULES[@]}; then
+ msg "module $m was already added"
+ return
+ fi
+
found=0
for path in $(find "${MODULEDIR}" -type f -name "${fil}.ko" -or -name "${fil}.ko.gz"); do
- #skip expensive stuff if this module has already been added
- if grep -q "file ${path} " "${FILELIST}"; then
- found=1
- continue
- fi
#get needed firmware files
for fw in $(/sbin/modinfo -F firmware "${path}"); do
[ -f "/lib/firmware/$fw" ] && add_file "/lib/firmware/$fw"
@@ -205,6 +207,7 @@ add_module ()
fi
done
HAS_MODULES="y"
+ ADDED_MODULES[${#ADDED_MODULES[*]}]="$m"
msg " adding module ${fil}"
add_file "${path}" && found=1
done