From 84f741e806597c869d10ae9eabbb369bf140acf4 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 2 Jan 2003 00:02:16 +0000 Subject: [PATCH] improved the efficiency of the isIn function as suggested by "John W. Krahn" --- lib/WebGUI/Utility.pm | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 0ec7cd227..701b375e4 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -98,23 +98,9 @@ An array to look for the value in. =cut sub isIn { - my ($i, @a, @b, @isect, %union, %isect, $e); - foreach $e (@_) { - if ($a[0] eq "") { - $a[0] = $e; - } else { - $b[$i] = $e; - $i++; - } - } - foreach $e (@a, @b) { $union{$e}++ && $isect{$e}++ } - @isect = keys %isect; - if (@isect) { - undef @isect; - return 1; - } else { - return 0; - } + my $key = shift; + $_ eq $key and return 1 for @_; + return 0; } #-------------------------------------------------------------------