On Sep 2, 2005, at 12:24 AM, Reinhard Pagitsch wrote:
I have since solved the problem another way, but while I was doing
so I
Can you tell us how you solved it? I think it would be of interest
for someone of us.
Nothing special.
First, I learned to live with some compromises which made large,
monolithic XSUBs workable -- for instance, I decided that the
do_packle engine XSUB would be equally strict about having TEMPLATE
and ITEMS match up regardless of whether it was called as a function
or as a method. (The original plan had been to have it be strict as
a method and loose as a function).
Furthermore, it was both possible and desirable to simplify the
internal implementation. I'd been trying to guess how long a char*
buffer I would need to hold the packled string, so I could allocate
memory for it as few times as possible, then creating an output SV*
from that char* buffer once at the end with newSVpvn. The algo
worked pretty well, but it was overlong and in the end, not
significantly faster than using sv_catpvn to append each additional
serialized item to a single output SV*. That guess-how-much-memory
algo was the main thing I'd wanted to offload to a helper sub, and by
getting rid of it, I no longer needed to refactor do_packle into
multiple subs which needed access to the same stack.
The solution with do_unpackle was different in its details, but
conceptually the same.
Best,
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/