[pacman-dev] [PATCH 1/2] Remove pre-optimization from in_array()

DJ Mills danielmills1 at gmail.com
Fri Jul 8 00:31:22 EDT 2011


The '[[ -z' test in in_array() doesn't really do anything, so I'm
removing it. I think this is much cleaner.

Signed-off-by: DJ Mills <danielmills1 at gmail.com>
---
 scripts/makepkg.sh.in |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 1b132a9..e215c4b 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -318,10 +318,8 @@ in_opt_array() {
 #          1 - not found
 ##
 in_array() {
-	local needle=$1; shift
-	[[ -z $1 ]] && return 1 # Not Found
-	local item
-	for item in "$@"; do
+	local needle=$1 item; shift
+	for item; do
 		[[ $item = $needle ]] && return 0 # Found
 	done
 	return 1 # Not Found
-- 
1.7.6



More information about the pacman-dev mailing list