RE: bug in trunk in Apache::Reload test

Mark Hedges <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <55EEF0B3C5BF2744B2248754D717EE4C4C146E@USASHEXMB02.LYV.LiveNation.com>
Nope Joshua you're right, I missed that.

defined() is faster than the logical check because the logical check checks defined, then checks if empty string, then checks if numerically 0, except if it is 0E0 (zero but true).  One operation versus the same operation plus three more; the one by itself is certainly less computation.

However I'm not sure about the last one.  That is a cool idea.  We'd have to benchmark it.  :-)

Also is '&&' faster than 'and'?

Mark



From: [email protected] [mailto:[email protected]] On Behalf Of Sergiy Borodych
Sent: Thursday, June 26, 2014 2:14 AM
To: Joshua Narins
Cc: Mark Hedges; [email protected]
Subject: Re: bug in trunk in Apache::Reload test

Hello,
another question:
 why not just 

my $args = $r->args;
if ( $args and $args eq 'last' ) {

(without defined)

or even

 if ( my $args = $r->args and $args eq 'last' ) {

:)

2014-06-26 10:52 GMT+03:00 Joshua Narins <[email protected]>:
On Mon, Jun 23, 2014 at 06:21:37PM +0000, Mark Hedges wrote:
> Perl 5.20.0, Apache 2.2.27, APR 1.5.1, APR-util 1.5.3, mod_perl trunk.
>
> 2014-06-23 11:16:32 Mon  $ svn diff t/lib/Apache2/TestReload.pm
> Index: t/lib/Apache2/TestReload.pm
> ===================================================================
> --- t/lib/Apache2/TestReload.pm             (revision 1604706)
> +++ t/lib/Apache2/TestReload.pm          (working copy)
> @@ -15,7 +15,8 @@
> sub handler {
>      my $r = shift;
>      $pass++;
> -    if ($r->args eq 'last') {
> +    my $args = $r->args;
> +    if (defined $args && $r->args eq 'last') {
>          Apache2::Reload->unregister_module($package);
>          ModPerl::Util::unload_package($package);
>          $pass = 0;

Why not just

my $args = $r->args;
if (defined $args and $args eq 'last') {

I guess repeat calls to $r->args have virtually no cost?



-- 
Sergiy Borodych
http://bor.org.ua
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.