in reply to Re: Increasing the efficiency of the code
in thread Increasing the efficiency of the code

Fengor,
If you implemented a hash with the numerical operators as keys and the string operators as their corresponding values couldn't you rewrite the whole if elsif else etc construct as:

You have a good idea and yes, it will lead to a performance increase. Unfortunately your implementation is less than desireable. Using a string eval can be very dangerous and should be avoided when better alternatives exist. In this case, a dispatch table is better suited. See my post below for an example.

Cheers - L~R

  • Comment on Re^2: Increasing the efficiency of the code

Replies are listed 'Best First'.
Re^3: Increasing the efficiency of the code
by Fengor (Pilgrim) on Nov 29, 2006 at 13:20 UTC
    hmm thx, at least tis good to know i wasnt totally on the wrong track. That dispatch table looks good guess its about time to add that trick to my book ;)

    --
    "WHAT CAN THE HARVEST HOPE FOR IF NOT THE CARE OF THE REAPER MAN"
    -- Terry Pratchett, "Reaper Man"