develooper Front page | perl.perl5.porters | Postings from August 2014

Missed optimization?

Thread Next
From:
H.Merijn Brand
Date:
August 19, 2014 17:42
Subject:
Missed optimization?
Message ID:
20140819194216.0904b417@pc09.procura.nl
I remember from long long ago that I timed the difference between
interpolation and concatenation and that there was no difference,
so I usually use interpolation rater than concatenation. Personal
preference, not because it is "better" (YMMV)

$ perl -MO=Terse -e'$a = "$b $a"'
LISTOP (0x13d9920) leave [1]
    OP (0x13d98e8) enter
    COP (0x13d9968) nextstate
    BINOP (0x13d99c8) sassign
        UNOP (0x13d9a48) null [68]
            OP (0x13d9a10) null [3]
            BINOP (0x13d9a90) concat [5]
                BINOP (0x13d7cb0) concat [3]
                    UNOP (0x13d7d38) null [15]
                        PADOP (0x13d7d78) gvsv  GV (0x13d14a8) *b
                    SVOP (0x13d7cf8) const [7] PV (0x13d1568) " "
                UNOP (0x13d9ad8) null [15]
                    PADOP (0x13d7c60) gvsv  GV (0x13d13b8) *a
        UNOP (0x13d7db8) null [15]
            PADOP (0x13d7df8) gvsv  GV (0x13d13b8) *a

$ perl -MO=Terse -e'$a = $b." ".$a'
LISTOP (0x18c19a0) leave [1]
    OP (0x18c1968) enter
    COP (0x18c19e8) nextstate
    BINOP (0x18c1a48) sassign
        BINOP (0x18c1a90) concat [5]
            BINOP (0x18bfcb0) concat [3]
                UNOP (0x18bfd38) null [15]
                    PADOP (0x18bfd78) gvsv  GV (0x18b9568) *b
                SVOP (0x18bfcf8) const [6] PV (0x18b9520) " "
            UNOP (0x18c1ad8) null [15]
                PADOP (0x18bfc60) gvsv  GV (0x18b93b8) *a
        UNOP (0x18bfdb8) null [15]
            PADOP (0x18bfdf8) gvsv  GV (0x18b93b8) *a

looks like the first can be optimized into the second (less OPs)

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.19   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About