in reply to Re^6: Does @{ } copy arrays?
in thread Does @{ } copy arrays?
an edge case
Do you consider your example the common case? Relative to all the readonly uses of $#{}. Eg. 0 .. $#a; there are myriad others.
dave_the_m suggested elsewhere that "$#{..} >= 0. As well as being uglier and more long winded than @{...},". Well, ditto scalar( @a ) - 1 versus $#a.
But as so often in these cases, discussion is not entertained.
On the basis of a very casual survey of code on my system and cpan, this "optimisation" is a space pessimisation if 9 cases out of 10 I looked at. In some cases, extremely.
I'd love to see the evidence justifying the addition of tens of words to any array that you reference $#, in order to save "1 pointers-worth of memory just to store NULL" on those you don't. And that's before you consider the peformance effects.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Does @{ } copy arrays?
by LanX (Saint) on Oct 19, 2009 at 13:37 UTC | |
by ikegami (Patriarch) on Oct 23, 2009 at 19:52 UTC | |
by BrowserUk (Patriarch) on Oct 23, 2009 at 22:22 UTC | |
by ikegami (Patriarch) on Oct 23, 2009 at 22:56 UTC | |
by LanX (Saint) on Oct 23, 2009 at 20:33 UTC | |
by ikegami (Patriarch) on Oct 23, 2009 at 20:45 UTC | |
by BrowserUk (Patriarch) on Oct 23, 2009 at 16:19 UTC | |
by LanX (Saint) on Oct 23, 2009 at 19:43 UTC | |
by BrowserUk (Patriarch) on Oct 23, 2009 at 22:11 UTC |