in reply to Re^14: Why does each() always re-evaluate its argument? ("for_list" )
in thread Why does each() always re-evaluate its argument?
Yes, because you separate the common case (non-magical) from the rare case with an if block, and then use the fast implementation most of the time. I didn't make up that example above, I copied it out of perl's own hv.c, where other various routines have been able to be optimized like that.
I also understand that there is probably a reason why they didn't optimize this case, but back to my original statement, it surprises me that this code path is using the normal iterator. I would think dumping the elements of a hash would be a frequent enough operation to be worth optimizing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^16: Why does each() always re-evaluate its argument? ("for_list" )
by ikegami (Patriarch) on Dec 12, 2023 at 05:16 UTC |