From 8ae47bcceffc955f1c68b0bb70d0cfd336e4a6ec Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 20 Oct 2015 18:17:08 +0000 Subject: [PATCH] scstadmin: Micro-optimize driverExists() git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6550 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm index 3c7b6423e..9b9e5db2f 100644 --- a/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-0.9.10/lib/SCST/SCST.pm @@ -922,18 +922,14 @@ sub targetGroupTargets { sub driverExists { my $self = shift; my $driver = shift; + my $dHandle = new IO::Handle; + my $result; - return FALSE if (!defined($driver)); + $result = defined($driver) && + opendir($dHandle, make_path(SCST_TARGETS_DIR(), $driver)); + close $dHandle if ($result); - my ($drivers, $errorString) = $self->drivers(); - - return SCST_C_FATAL_ERROR if (!defined($drivers)); - - foreach my $_driver (@{$drivers}) { - return TRUE if ($driver eq $_driver); - } - - return FALSE; + return $result; } sub driverDynamicAttributes {