in reply to Re: Optimizing the bejeezus out of a sub
in thread Optimizing the bejeezus out of a sub

The listification of @_ was optimized away by perl so foreach accessed the array directly. Using offsets to counteract the not-actually-happening maloptimization is a maloptimization in and of itself.

  • Comment on Re: Re: Optimizing the bejeezus out of a sub

Replies are listed 'Best First'.
Re: Re: Re: Optimizing the bejeezus out of a sub
by BrowserUk (Patriarch) on Jun 24, 2003 at 13:27 UTC

    I said might!

    Can you substantiate that the listification is always optimised away?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


      No. I verified that the case of for(LIST(@_)){ ... } is optimized away into for(@_){ ... } because that is what is in the original code. I also (since you just asked) tried for(@A,@B), for(@A,@B,1) and in all cases the list op was removed. Maybe the list op shows back up when there is something non-simple to read from - functions and builtins.

        That's good to know, thanks.

        Which version are you checking this on? And do you know if this is a recent change?

        I ask because I had at least one situation where for (@array){...} definitly (seemed to?) caused a very large list to be built. At least, that's what my testing (basically watching the memory grow) showed under 5.6.1.

        Update Seems I didn't keep the script, and I can't seem to reproduce the behaviour either.

        I'm looking now to see if I can locate the program.

        I assume that you're determining this by looking at the opcodes (as is your want:)?


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller