On 9 March 2015 at 03:11, Артём Варнайский <varnays...@mail.ru> wrote:

> due to performance issues



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

Then your concerns may be unjustified.

After proving the concern justified, realise there are not many solutions
you can use here that won't make the code less elegant than it already is.

Options presently appear as either

a) source filters ( danger will robinson )
b) XS ( effort will robinson )
c) OP tree optimisers that eliminate the function call overhead ( magic and
effort and danger will robinson )
d) code templates ( can be ugly, and is not recommended for a mere 5
invocations )

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

( Sometimes people over-apply DRY to mean things it shouldn't )

As to "d", that is basically suggesting something that generates the sub
itself, such as using string building, compiling the string from parts, and
then creating a sub from the string with eval.

That is very much not for beginners, and the ugliness and risks associated
with that technique would certainly require demonstration that it was
justified.

-- 
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

Reply via email to