This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
store AV iterator as mg_len in more cases
authorZefram <zefram@fysh.org>
Sat, 11 Nov 2017 04:06:59 +0000 (04:06 +0000)
committerZefram <zefram@fysh.org>
Sat, 11 Nov 2017 04:23:37 +0000 (04:23 +0000)
commit4803e7f74216e2e7d916ba267af33207459d1c8b
treedbf79928d645093494446ec919540ff6f7290962
parent7b1af8a66568cbb1b215ecb17fa5f19059208f55
store AV iterator as mg_len in more cases

The iterator of an AV is an IV value attached to the AV via magic.
It may be stored in the space used by mg_len, or it may be stored in
separately allocated space referenced by mg_ptr.  The former is more
efficient, so should be preferred.  The original code for AV iterators
would use mg_len if IV was (the same size as) I32, because mg_len was of
type I32.  Since then mg_len has been increased to type SSize_t, but the
conditional about how AV iterators are stored wasn't updated to match.
As a result, on the now very common 64-bit builds we were missing out on
the opportunity to use the more efficient form of storage.  This commit
updates the condition about how AV iterators are stored, to take account
of the new type.

In principle AV iterators ought to be of type SSize_t, and thus *always*
storable as mg_len.  But Perl_av_iter_p() is in the public API with
its IV* return type, so there is a compatibility issue to address in
changing that.
av.c
mg.c