Clear questions and runnable code
get the best and fastest answer
Re^2: Factoring out common code in two methods of a classby jvector (Friar)
|on Aug 05, 2009 at 18:48 UTC
Thanks for that. I had wondered about "use constant..." but had it in my head that I would need a constant for each 'field' and been put off by the anticipated verbosity of it. But I had been blinkered about putting them all into one constant.
I guess I'll have to leave off the last two parts which in this application are optional, and add them to PACK_TEMPLATE programatically after the length field ... hmm, that's OK.
And yes, you're right that there is a performance implication on constructing that format string each time. Not a lot, but every little bit hurts...
The next signature will be better than this one