-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Theo Van Dinter writes:
> On Mon, Nov 21, 2005 at 01:02:13PM -0500, Dallas Engelken wrote:
> an easy solution would be to change the code from:
> 
> if (my $result = ( $self->{'tests_already_hit'}->{'__HTML_LENGTH_384'} && 
> $self->{'tests_already_hit'}->{'__TAG_EXISTS_CENTER'} ) ) { 
> $self->got_hit(q#HTML_SHORT_CENTER#, "", $result); }
> 
> to:
> 
> $result = ( $self->{'tests_already_hit'}->{'__HTML_LENGTH_384'} && 
> $self->{'tests_already_hit'}->{'__TAG_EXISTS_CENTER'} );
> if ($result) { $self->got_hit(q#HTML_SHORT_CENTER#, "", $result); }
> 
> that way the original version would become:
> 
> $result = 0;
> if ($result) { $self->got_hit(q#SARE_OBFU_OBLIGATION#, "", $result); }
> 
> and do the "my $result" before the tests run.

+1.

Before:

perl -MO=Terse -e 'my $t=[1,1]; if (my $r = ($t->[0] && $t->[1])) { print "y 
$r\n";}'

LISTOP (0x81551a0) leave [1]
    OP (0x816bcc0) enter
    COP (0x816af70) nextstate
    BINOP (0x816afd0) sassign
        UNOP (0x81550e0) srefgen
            UNOP (0x816b0d8) null [141]
                LISTOP (0x816b250) anonlist
                    OP (0x816af30) pushmark
                    SVOP (0x816b110) const [8] IV (0x814d6f0) 1
                    SVOP (0x816b1f8) const [9] IV (0x814d6fc) 1
        OP (0x8169b48) padsv [1]
    COP (0x816b078) nextstate
    UNOP (0x8162c68) null
        LOGOP (0x8162c40) and
            BINOP (0x8257288) sassign
                UNOP (0x8230cd0) null
                    LOGOP (0x81ccad8) and
                        BINOP (0x8155178) aelem
                            UNOP (0x816af50) rv2av [3]
                                OP (0x8155138) padsv [1]
                            SVOP (0x816af00) const [10] IV (0x814d7a4) 0
                        BINOP (0x8155098) aelem
                            UNOP (0x816b3b8) rv2av [4]
                                OP (0x816b058) padsv [1]
                            SVOP (0x8162bf8) const [11] IV (0x814d774) 1
                OP (0x816aee0) padsv [2]
            LISTOP (0x816bc70) scope
                OP (0x816aff8) null [174]
                LISTOP (0x816bc28) print
                    OP (0x816bc50) pushmark
                    UNOP (0x8169ba0) null [67]
                        OP (0x8169bc8) null [3]
                        BINOP (0x8169b78) concat [6]
                            BINOP (0x816bc00) concat [5]
                                SVOP (0x81839f8) const [12] PV (0x814d744) "y "
                                OP (0x816bbc0) padsv [2]
                            SVOP (0x816bbe0) const [13] PV (0x814d738) "\n"
- -e syntax OK


after:

: jm 572...; perl -MO=Terse -e 'my $t=[1,1]; my $r; if ($r = ($t->[0] && 
$t->[1])) { print "y $r\n";}'
LISTOP (0x81551a0) leave [1]
    OP (0x816bd80) enter
    COP (0x816af78) nextstate
    BINOP (0x816afd8) sassign
        UNOP (0x81550e0) srefgen
            UNOP (0x816b0e0) null [141]
                LISTOP (0x816b258) anonlist
                    OP (0x816af38) pushmark
                    SVOP (0x816b118) const [8] IV (0x814d6f0) 1
                    SVOP (0x816b200) const [9] IV (0x814d6fc) 1
        OP (0x8169b50) padsv [1]
    COP (0x816b000) nextstate
    OP (0x816aee8) padsv [2]
    COP (0x816bd18) nextstate
    UNOP (0x8162c68) null
        LOGOP (0x8162c40) and
            BINOP (0x8257290) sassign
                UNOP (0x8183a00) null
                    LOGOP (0x81ccae0) and
                        BINOP (0x8155178) aelem
                            UNOP (0x816b060) rv2av [3]
                                OP (0x816af08) padsv [1]
                            SVOP (0x816af58) const [10] IV (0x814d7a4) 0
                        BINOP (0x8155098) aelem
                            UNOP (0x8230cd8) rv2av [4]
                                OP (0x8162bf8) padsv [1]
                            SVOP (0x816b3c0) const [11] IV (0x814d774) 1
                OP (0x8155138) padsv [2]
            LISTOP (0x816bcf0) scope
                OP (0x816b080) null [174]
                LISTOP (0x816bca8) print
                    OP (0x816bcd0) pushmark
                    UNOP (0x816bbf0) null [67]
                        OP (0x816bc18) null [3]
                        BINOP (0x816bbc8) concat [6]
                            BINOP (0x8169bd8) concat [5]
                                SVOP (0x816bc48) const [12] PV (0x814d744) "y "
                                OP (0x816bc68) padsv [2]
                            SVOP (0x816bc88) const [13] PV (0x814d738) "\n"
- -e syntax OK

The "my $result;" line is the only one that imposes a speed hit -- namely
the two opcodes to allocate its stack space:

    OP (0x816aee8) padsv [2]
    COP (0x816bd18) nextstate

Everything else is pretty much identical. As long as that is declared
sufficiently early and "high" in scope, that should work just fine.

- --j.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Exmh CVS

iD8DBQFDgk1lMJF5cimLx9ARApZyAJ980OvjCTeOGqfBrdV49Z/SJFOOeQCfQfg9
Ksg6pKqC7RTEJ9ISZjqFxuQ=
=b3e5
-----END PGP SIGNATURE-----

Reply via email to