develooper Front page | perl.perl5.porters | Postings from October 2014

[perl #121845] EXTEND_MORTAL usage is questionable

Thread Previous
From:
Tony Cook via RT
Date:
October 8, 2014 03:49
Subject:
[perl #121845] EXTEND_MORTAL usage is questionable
Message ID:
rt-4.0.18-21001-1412740140-1251.121845-15-0@perl.org
On Sat May 10 21:57:01 2014, bulk88 wrote:
> While looking through the core, I found usage of the EXTEND_MORTAL
> macro. It seems to be used as an optimization for later sv_newmortal
> or
> sv_2mortal calls. The problem is, EXTEND_MORTAL is executed AGAIN in
> every sv_newmortal and sv_2mortal through PUSH_EXTEND_MORTAL__SV_C.

Most of the EXTEND_MORTAL() calls I see make sense in the case where the code might return a large number of mortals, like in pp_aassign and pp_mapwhile, since it will avoid expensive reallocations of PL_tmps_stack.

It's obviously much less useful in some other places:

- pp_stat - it always returns 0 or 13 items, and 13 is well below the minimum growth size (128)

- pp_gmtime - always extends by 1 or 9.

Do any of the other uses strike you as wasteful or incorrect?

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=121845

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About