This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Data::Dumper: move sortkeys setting into style struct
On Perl 5.6, there is no sortsv() function available to XS code, so
Data::Dumper used a Perl helper function. The name of that helper function
was allocated as a (mortal) SV, but that was done lazily, the first time the
helper was needed. This meant that the "sortkeys" C variable was mutable,
and therefore it couldn't be easily moved to the struct.
I think it's a better trade-off to allocate the SV in all cases under 5.6:
when dumping a data structure containing no hashes, we now allocate this SV
unnecessarily, but we save an extra pointer on the stack in every recursive
call frame.
In addition, Data::Dumper doesn't currently work on 5.6 as far as I can tell,
so this change certainly doesn't make anything any worse. I've nonetheless
attempted to restore 5.6 compatibility in this narrow area surrounding the
sortkeys option: in particular, a sortsv() call appeared in code that was
compiled under 5.6, but has now been moved to a block that's compiled only
under later Perls. I haven't been able to test this change on 5.6, though.