Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | menu_no_array_shift-172764-4.patch | 1.17 KB | chx |
#3 | no_shift_menu_2.patch | 1.34 KB | pwolanin |
no_shift_menu_1.patch | 1.22 KB | pwolanin | |
Comments
Comment #1
chx CreditAttribution: chx commentedthis prints
bar
so I think the use ofnext
might not result in what we want.each
could be, but then you need tolist
as well. I am fairly sure that this pair of functions is still (much) faster though.Comment #2
pwolanin CreditAttribution: pwolanin commentedAh, yes - stupid of me. I was confused by the PHP doc that says it works like current().
Comment #3
pwolanin CreditAttribution: pwolanin commentedhow about this instead?
Comment #4
chx CreditAttribution: chx commentedAnd what do you think of this version?
Comment #5
pwolanin CreditAttribution: pwolanin commentedlooks pretty good - though we don't even need the $key in the foreach
Comment #6
owahab CreditAttribution: owahab commentedI think the existence of $key is good for readability.
Yet the code is RTBC IMHO.
Comment #7
Gábor HojtsyLooks ok, committed.
Comment #8
(not verified) CreditAttribution: commented