On Wed, Feb 16, 2011 at 10:17:17AM +0100, Martin Gruner wrote: > Hi Thomas, > > we would definitely be interested. Can I ask you to do the following: > - open a bug report for this > - attach a test case which shows the performance problem (e. g. a file > with data which causes the problem when fed into the function) > - attach your patch
After wrangling for a while with Bugzilla, I gave up (too tight in time). Anyway, I attach two patches here, in case they are useful: * output_filter_text_url.patch * html_utils.patch Both patches are taken against 2.4.7. The first one applies cleanly to HEAD, the second doesn't (although the code follows the same pattern). Both are variations on the same theme: replace a loop doing substitutions over and over by just one substitution. Both cut page latencies in some cases by as much as 30 seconds (on very big pages, when there are lots of links). I hope it's useful as is. Regards -- tomás
--- otrs/Kernel/Output/HTML/OutputFilterTextURL.pm (revision 3218)
+++ otrs/Kernel/Output/HTML/OutputFilterTextURL.pm (revision 3404)
@@ -101,11 +101,5 @@
if ( $Self->{LinkHash} ) {
- for my $Key ( sort keys %{ $Self->{LinkHash} } ) {
- my $LinkSmall = $Self->{LinkHash}->{$Key};
- $LinkSmall =~ s/^(.{75}).*$/$1\[\.\.\]/gs;
- $Self->{LinkHash}->{$Key} =~ s/ //g;
- ${ $Param{Data} }
- =~ s/\Q$Key\E/<a href=\"$Self->{LinkHash}->{$Key}\" target=\"_blank\" title=\"$Self->{LinkHash}->{$Key}\">$LinkSmall<\/a>/;
- }
+ ${$Param{Data}} =~ s/(\[#{10,}\d+\])/$Self->_renderlink($1)/eg;
}
@@ -113,3 +107,12 @@
}
+sub _renderlink {
+ my($Self, $key) = @_;
+ my $lnk = $Self->{LinkHash}->{$key};
+ return $key unless defined $lnk; # leave alone when not really link
+ my $short = length($lnk) <= 75 ? $lnk : substr($lnk, 0, 75) . '[..]';
+ $lnk =~ s/ //g; # FIXME: copied from original. Why is that?
+ return "<a href=\"$lnk\" target=\"_blank\" title=\"$lnk\">$short</a>";
+}
+
1;
--- otrs/Kernel/System/HTMLUtils.pm (revision 3302)
+++ otrs/Kernel/System/HTMLUtils.pm (revision 3405)
@@ -818,7 +818,5 @@
# add already existing "<a href" again
- for my $Key ( keys %LinkHash ) {
- ${$String} =~ s/$Key/$LinkHash{$Key}/g;
- }
+ ${$String} =~ s/#{12}LinkHash-\d+#{12}/$LinkHash{$&} || $&/eg;
# check ref && return result like called
signature.asc
Description: Digital signature
--------------------------------------------------------------------- OTRS mailing list: otrs - Webpage: http://otrs.org/ Archive: http://lists.otrs.org/pipermail/otrs To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs
