Skip Menu |

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 38537
Status: resolved
Priority: 0/
Queue: Log-Log4perl

People
Owner: Nobody in particular
Requestors: AGRUNDMA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.17
Fixed in: (no value)



Subject: [PATCH] 47% performance boost for is_foo methods
I noticed the is_foo methods perform a lot more work than they need to: 2 string concats and a defined check that seems useless. This patch improves performance of these calls by about 47%. Another small gain can be realized if you don't pass the 2 args to the is_foo method unless WATCHER is set, but I couldn't get 027Watch2 and 027Watch3 to pass in that case.
Subject: is_foo_boost.patch
diff -ur Log-Log4perl-1.17/lib/Log/Log4perl/Logger.pm Log-Log4perl-1.17-new/lib/Log/Log4perl/Logger.pm --- Log-Log4perl-1.17/lib/Log/Log4perl/Logger.pm 2008-08-17 09:48:34.000000000 -0400 +++ Log-Log4perl-1.17-new/lib/Log/Log4perl/Logger.pm 2008-08-17 09:49:09.000000000 -0400 @@ -773,10 +773,12 @@ # Added these to have is_xxx functions as fast as xxx functions # -ms + + my $islevel = "is_" . $level; + my $islclevel = "is_" . $lclevel; *{__PACKAGE__ . "::is_$lclevel"} = sub { - $_[0]->{"is_" . $level}->($_[0], "is_" . $lclevel) if - defined $_[0]->{$level}; + $_[0]->{$islevel}->($_[0], $islclevel); }; # Add the isXxxEnabled() methods as identical to the is_xxx
On Sun Aug 17 09:51:07 2008, AGRUNDMA wrote: Show quoted text
> I noticed the is_foo methods perform a lot more work than they need to: > 2 string concats and a defined check that seems useless.
Patch applied, will be released with 1.18. Thanks much, Andy, great work! -- Mike
Applied to 1.18