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 <dyadyushkin.a@raidix.com>


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9485 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2021-07-12 03:45:32 +00:00
parent 6abef3d29c
commit a4b3805d11

View File

@@ -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__