We can easily remove most of the uses of array_shift() form menu.inc. As recent posts have noted, this is a very slow function because it requires re-indexing the whole array.

Comments

chx’s picture

Status: Needs review » Needs work
$a = array('foo', 'bar');
print next($a);

this prints bar so I think the use of next might not result in what we want. each could be, but then you need to list as well. I am fairly sure that this pair of functions is still (much) faster though.

pwolanin’s picture

Ah, yes - stupid of me. I was confused by the PHP doc that says it works like current().

pwolanin’s picture

FileSize
1.34 KB

how about this instead?

chx’s picture

Status: Needs work » Needs review
FileSize
1.17 KB

And what do you think of this version?

pwolanin’s picture

looks pretty good - though we don't even need the $key in the foreach

owahab’s picture

Status: Needs review » Reviewed & tested by the community

I think the existence of $key is good for readability.
Yet the code is RTBC IMHO.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Looks ok, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)