develooper Front page | perl.perl5.porters | Postings from February 2018

[perl #8910] Subroutine doesn't create elements.

Thread Previous
Father Chrysostomos via RT
February 19, 2018 02:11
[perl #8910] Subroutine doesn't create elements.
Message ID:
On Sun, 21 Jan 2018 21:59:24 -0800, sprout wrote:
> Please review the ‘Nonelem’ patch in the sprout/nonelem branch.  It
> currently fixes #132729 only for the cases covered by this ticket
> (S_pushav), but it could be extended to other uses of deferred
> elements.  However, it would only be a partial fix for #132729, not
> applying to elephants beyond the end of the array.  Fixing *that*
> would be harder, but doable (but probably too intrusive for 5.28).  It
> is worth applying a partial fix?

Replying to myself, I think it is worth it, because most Perl programmers probably do not realize that arrays can have holes in them.

I have applied my fix in the branch merged as 2a05854.

> The commit does not yet include tests for #132729 or for the memory
> leaks it fixes.

The branch includes that.

> I also have not had time yet to benchmark it.

I know my method is primitive, but it should not matter considering the stark difference:

$ time ./miniperl -e '$#a++; for (1..5000000) { map 1, @a }'

real	0m7.991s
user	0m7.272s
sys	0m0.703s

$ time ./newminiperl -e '$#a++; for (1..5000000) { map 1, @a }'

real	0m4.503s
user	0m4.490s
sys	0m0.006s

The first is blead before the merge (with my previous, inefficient defelem fix). The second is after the merge.


Father Chrysostomos

via perlbug:  queue: perl5 status: open

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About