This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid creating lots of mortals in B::walkoptree()
authorNicholas Clark <nick@ccl4.org>
Fri, 5 Nov 2010 13:51:46 +0000 (13:51 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 5 Nov 2010 13:51:46 +0000 (13:51 +0000)
commit20f7624e3fd0a2888bfc8c1fd98f11e603f108e9
tree147a932d13874f90d0f8c2d01fbd74e8a00c71f3
parent98517ccb8d5e8751980561f66bf6a58aca163de1
Avoid creating lots of mortals in B::walkoptree()

When calling out to the user-supplied method, re-use the same reference and
object where possible. Only create a new one if the user supplied method
modified the reference or object passed to it.

The previous implementation had a comment "Use the same opsv. Rely on methods
not to mess it up." but it was actually generating a new reference for every
call, and also a new object for every recursive call. So massive churn of
objects, and large accumulation of mortals on the temp stack.
ext/B/B.xs
ext/B/t/walkoptree.t