Add `av_unshift_sv()`
A new API function to handle this case, avoiding the need to unshift + assign separately.
A not-very-optimal implementation at present. A better one could be provided perhaps by merging the logic into Perl_av_unshift itself, but that is left for a later exercise.
My intuition is that should should also have a av_unshift_svs that takes an array of SV*,
Thinking about it, av_store()'s return value is significant - and in this case that can be a problem if the av is tied
For normal arrays av takes ownership of a reference count of the supplied val, but when av is tied av_store() returns NULL and the caller is responsible for that reference count, and this implementation doesn't handle that, and doesn't allow the caller to handle that.
Perhaps it should:
assert(mg_find((const SV *)av, PERL_MAGIC_tied) == NULL);
Similarly for the proposed av_unshift_svs() -- which I don't think needs to be part of this ticket.
A new API function to handle this case, avoiding the need to unshift + assign separately.
A not-very-optimal implementation at present. A better one could be provided perhaps by merging the logic into
Perl_av_unshiftitself, but that is left for a later exercise.
@leonerd, both @Leont and @tonycoz have raised questions about this p.r. Do you wish to pursue it further? Thanks.
A new API function to handle this case, avoiding the need to unshift + assign separately. A not-very-optimal implementation at present. A better one could be provided perhaps by merging the logic into
Perl_av_unshiftitself, but that is left for a later exercise.@leonerd, both @Leont and @tonycoz have raised questions about this p.r. Do you wish to pursue it further? Thanks.
@leonerd, ^^