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