This is a performance issue for a number of reasons, but most notably, as
CC has pointed out many times, because of the overhead of compilation.
There is an opportunity here to factor out common code in the same way thet
TWiki::Func
does.
One of my favourite code fragments is :-
sub replaceVars {
my ($format, $data) = @_;
if (defined $data) {
if (defined $data->{wikiname}) {
$data->{username} = &TWiki::Func::wikiToUserName($data->{wikiname});
$data->{wikiusername} = &TWiki::Func::userToWikiName($data->{wikiname});
}
foreach my $key (keys %$data) {
$format =~ s/\$$key/$data->{$key}/g;
}
}
$format =~ s/\$n\b/\n/g;
$format =~ s/\$quot\b/\"/gos;
$format =~ s/\$percnt\b/\%/gos;
$format =~ s/\$dollar\b/\$/gos;
return $format;
}
Is this better as a core module or a Contrib?