Kent wrote:
>Important question:
>
>How did you prove this was a performance issue.
>
>Because unless you've
>
>a) profiled your code
>b) benchmarked your code
>c) seen that the performance is significantly impeded by that function call
>d) seen that the performance is in the function overhead itself in that 
>function call

I used a nytprof to check performance, function call reduces it.

>It may be simpler and more elegant to just write that line of code in the 5 
>places by hand.
I think you right.

Shlomi Fish
>Some ideas:
>
>1. Implement the subroutine in XS using https://metacpan.org/release/Inline-C
>or whatever.
>
>2. Create a code like:
>
>sub my_RAND_SUB_PLEASE_EXPAND
>{
>return (int ( rand 2 ) ? 1 : -1);
>}

...

>And then compile the code to a more optimised version by passing it through a 
>filter such as:

>perl -lapE 's/\Qmy_RAND_SUB_PLEASE_EXPAND()\E/(int ( rand 2 ) ? 1 : -1)/g'

Too little reason to add new dependencies from CPAN and use such a powerful 
magic :)
But source filters seems interesting to me. I think I'll find use for them in 
the future.

Kent, Shlomi Fish, thanks for your replies!

Reply via email to