[Melbourne-pm] scalar(keys %foo)

Dean Hamstead dean at fragfest.com.au
Mon Jun 1 23:46:24 PDT 2020


it fetches HvUSEDKEYS(hv);

which generally just fetches a structure member (it's a little more
complex if you're iterating over the has, or if it's tied) 

Dean 

On 2020-06-01 20:06, Mathew Robertson wrote:

> A question for the audience. 
> 
> Does "scalar(keys %foo)" materialise the list of keys, grabs its length, then throw away the memory?  .. or is Perl smart enough to see that context, to understand that it just needs to count the keys ? 
> 
> thx 
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> https://mail.pm.org/mailman/listinfo/melbourne-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20200601/50a59809/attachment.html>


More information about the Melbourne-pm mailing list