summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-09-17 16:29:01 +0200
committerDave Reisner <dreisner@archlinux.org>2012-09-17 16:49:44 +0200
commitb8d9c5cd2753e924150f7d3b9081a5e1c2cafad2 (patch)
treee2279793a78ec826e83b0c9c584b1e6094b3bd06
parent41eb799039a7a7fd00471642c06318f53e633134 (diff)
downloadmkinitcpio-b8d9c5cd2753e924150f7d3b9081a5e1c2cafad2.tar.gz
mkinitcpio-b8d9c5cd2753e924150f7d3b9081a5e1c2cafad2.tar.xz
declare ADDED_MODULES as associative array
Lookups in the hash table are far faster than traversing the entire array, as this grows O(n) and introduces a particularly noticeable slowdown on larger images. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--functions4
-rwxr-xr-xmkinitcpio4
2 files changed, 4 insertions, 4 deletions
diff --git a/functions b/functions
index 8a270fd..107319f 100644
--- a/functions
+++ b/functions
@@ -313,7 +313,7 @@ add_module() {
module=${1%.ko*}
# skip expensive stuff if this module has already been added
- in_array "${module//-/_}" "${ADDED_MODULES[@]}" && return
+ (( ${ADDED_MODULES["$module"]} )) && return
while IFS=':= ' read -r -d '' field value; do
case "$field" in
@@ -343,7 +343,7 @@ add_module() {
# aggregate modules and add them all at once to save some forks
(( QUIET )) || plain "adding module: %s" "$1"
MODPATHS+=("$path")
- ADDED_MODULES+=("${module//-/_}")
+ ADDED_MODULES["${module//-/_}"]=1
# handle module quirks
case $module in
diff --git a/mkinitcpio b/mkinitcpio
index 5bed94e..5ea02dd 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -18,8 +18,8 @@ COMPRESSION=gzip
declare MODULE_FILE= GENIMG= PRESET= COMPRESSION_OPTIONS= BUILDROOT=
declare NC= BOLD= BLUE= GREEN= RED= YELLOW=
declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 COLOR=1
-declare -a SKIPHOOKS ADDED_MODULES MODPATHS
-declare -A RUNHOOKS
+declare -a SKIPHOOKS MODPATHS
+declare -A RUNHOOKS ADDED_MODULES
# export a sane PATH
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'