From: Peter Rabbitson Date: Thu, 22 Dec 2011 23:12:04 +0000 (+0100) Subject: Simplify even more - we don't care about context anymore X-Git-Tag: 0.22~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2Fnamespace-clean.git;a=commitdiff_plain;h=4dc0aa54c2e120dda9c9b143df62963ffc91a508 Simplify even more - we don't care about context anymore --- diff --git a/lib/namespace/clean/_PP_OSE.pm b/lib/namespace/clean/_PP_OSE.pm index 25f44af..6fdc447 100644 --- a/lib/namespace/clean/_PP_OSE.pm +++ b/lib/namespace/clean/_PP_OSE.pm @@ -15,22 +15,15 @@ use Hash::Util::FieldHash 'fieldhash'; # # Therefore the DELETE of a tied fieldhash containing a %^H reference will # be the hook to fire all our callbacks. -# -# The SUPER:: gimmick is there to ensure the fieldhash is cleaned up in a -# timely manner. When you call delete() in non-void context, you get a mortal -# scalar whose reference count decreases at the end of the current statement. -# During scope exit, ‘statement’ is not clearly defined, so more scope -# unwinding could happen before the mortal gets freed. Forcing the DELETE -# in void context localizes the life of the mortal scalar. fieldhash my %hh; { package namespace::clean::_TieHintHashFieldHash; use base 'Tie::StdHash'; sub DELETE { - $_->() for @{ $_[0]->{$_[1]} }; - shift->SUPER::DELETE(@_); - 1; # put the preceding statement in void context so the free is immediate + my $ret = shift->SUPER::DELETE(@_); + $_->() for @$ret; + $ret; } }