AttrTemplate.pm: fix performance problem for large installations (Forum #98465)

git-svn-id: https://svn.fhem.de/fhem/trunk@18877 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2019-03-12 18:16:45 +00:00
parent 5ed5a653cc
commit 36730948fe
2 changed files with 8 additions and 6 deletions

View File

@@ -77,7 +77,8 @@ AttrTemplate_Set($$@)
my @list;
for my $k (sort keys %templates) {
my $h = $templates{$k};
my $matches = grep /$name/, devspec2array($h->{filter}) if($h->{filter});
my $matches;
$matches = devspec2array($h->{filter}, undef, [$name]) if($h->{filter});
if(!$h->{filter} || $matches) {
push @list, $k;
$haveDesc = 1 if($h->{desc});
@@ -97,7 +98,8 @@ AttrTemplate_Set($$@)
my @hlp;
for my $k (sort keys %templates) {
my $h = $templates{$k};
my $matches = grep /$name/, devspec2array($h->{filter}) if($h->{filter});
my $matches;
$matches = devspec2array($h->{filter}, undef, [$name]) if($h->{filter});
if(!$h->{filter} || $matches) {
push @hlp, "$k: $h->{desc}" if($h->{desc});
}

View File

@@ -120,7 +120,7 @@ sub concatc($$$);
sub configDBUsed();
sub createNtfyHash();
sub createUniqueId();
sub devspec2array($;$);
sub devspec2array($;$$);
sub doGlobalDef($);
sub escapeLogLine($);
sub evalStateFormat($);
@@ -1238,9 +1238,9 @@ AnalyzeCommand($$;$)
}
sub
devspec2array($;$)
devspec2array($;$$)
{
my ($name, $cl) = @_;
my ($name, $cl, $initialList) = @_;
return "" if(!defined($name));
if(defined($defs{$name})) {
@@ -1262,7 +1262,7 @@ devspec2array($;$)
next;
}
my @names = sort keys %defs;
my @names = $initialList ? @{$initialList} : sort keys %defs;
my @res;
foreach my $dName (split(":FILTER=", $l)) {
my ($n,$op,$re) = ("NAME","=",$dName);