Oops, I forgot what this thread was really about when I posted. $#array is fixed. AvARYLEN isn't changed. AvARYLEN doesn't exist as a field, so don't try to measure its size. The following code shouldn't be executed in 5.10+:
if (AvARYLEN(thing)) {
if (check_new(tv, AvARYLEN(thing))) {
total_size += thing_size(AvARYLEN(thing), tv);
}
}
Test with bleadperl and with those lines present:
perl -MDevel::Peek -MDevel::Size=total_size -wle'
my @a = qw( a b c );
Dump(\@a,1); # Shows no magic
print total_size \@a; # 224
Dump(\@a,1); # Shows magic
$#a=$#a; # Add magic
Dump(\@a,1); # Shows magic
print total_size \@a; # 224
'
Test with bleadperl and with those lines commented out:
perl -MDevel::Peek -MDevel::Size=total_size -wle'
my @a = qw( a b c );
Dump(\@a,1); # Shows no magic
print total_size \@a; # 168
Dump(\@a,1); # Shows no magic
$#a=$#a; # Add magic
Dump(\@a,1); # Shows magic
print total_size \@a; # 224
'
Update: Fixed reply to reflect the actual usage of AvARYLEN by the module. It's not used to determine the length of arrays as I had originally indicated.
Update: Added tests. |