Skip to content

Commit

Permalink
Item14387: performance sorting template candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed May 2, 2017
1 parent e99c735 commit 246a12a
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions core/lib/Foswiki/Templates.pm
Expand Up @@ -509,25 +509,15 @@ sub _readTemplateFile {
tertiary => $templateixd,
file => $file,
userdir => $userdir,
skin => $skin
skin => $skin,
order => $isSkinned * 1000000 + $idx * 1000 + $templateixd,
}
);
}
}

# sort
@candidates = sort {
foreach my $i (qw/primary secondary tertiary/)
{
if ( $a->{$i} < $b->{$i} ) {
return -1;
}
elsif ( $a->{$i} > $b->{$i} ) {
return 1;
}
}
return 0;
} @candidates;
@candidates = sort { $a->{order} <=> $b->{order} } @candidates;

foreach my $candidate (@candidates) {
my $file = $candidate->{file};
Expand Down

0 comments on commit 246a12a

Please sign in to comment.