From b8d9c5cd2753e924150f7d3b9081a5e1c2cafad2 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Mon, 17 Sep 2012 10:29:01 -0400 Subject: 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 --- functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'functions') 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 -- cgit v1.2.3-24-g4f1b