From a4b3805d11fc1ed2bd0d7cbc3e78e6d8debdcde8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 12 Jul 2021 03:45:32 +0000 Subject: [PATCH] scstadmin: Improve performance of make_path() Since `make_path` is called in pretty much any interaction with sysfs, speed degradation in it has visible impact when plenty of resources being managed. So much that it reaches the same great execution time as calls to filesystem, such as `-d`. Reported-by: Dyadyushkin Aleksandr git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9485 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- .../scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm index 5a5ab48b2..df34d0052 100644 --- a/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm +++ b/scstadmin/scstadmin.sysfs/scst-1.0.0/lib/SCST/SCST.pm @@ -11,6 +11,7 @@ use strict; use warnings; use 5.005; use Fcntl ':mode'; +use File::Spec; use IO::Handle; use IO::File; use Carp qw(cluck); @@ -4635,17 +4636,7 @@ sub _syswrite { } sub make_path { - my $path; - - foreach my $element (@_) { - if ($path && rindex($path, '/') != length($path) - 1) { - $path .= '/'; - } - cluck("make_path: invalid argument") if !valid($element); - $path .= $element; - } - - return $path; + return File::Spec->catdir(@_); } ;1 __END__