in reply to Re^5: Macro in perl code?
in thread Macro in perl code?
Ah.. no wonder I couldn't make it work...
I am using a runtime condition. The idea was rather than call a function which evaluates the cond and may simply exit, put the code inline and avoid the function call overhead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Macro in perl code?
by shmem (Chancellor) on Oct 17, 2007 at 19:44 UTC | |
But! since you wrote My script has the global $verbosity which is set by command line args. I ask - does this value change ever after? Because if not, you can make that a static via
of course only after examining under severe scrutiny what $verbosity holds (untaint, perlsec). Since the BEGIN block is a separate compile & run, the sub is defined and a constant sub after that, and its value can be used for optimizations. If the values you compare $verbose with are plain numbers as the 1 in
then optimization should work, because then you have constant vs. constant comparisons. Let's see...
bingo :-) --shmem
| [reply] [d/l] [select] |
|
Re^7: Macro in perl code?
by ikegami (Patriarch) on Oct 17, 2007 at 19:53 UTC | |
It sounds like you have a limited number of conditions (the different levels of verbosity), so you could something like the following:
Update: Ah woops! There'll be a prototype mismatch. The best you can do (without playing with the opcode tree) is:
Tested
I'm betting this is the fastest you'll get. | [reply] [d/l] [select] |