This is a quick optimization of the menu_tree_output() function.

You check for the last item doing a $num_items - 1 each time. Instead, I suggest you use $last_item that was already decremented. You do not use the $num_items otherwise.

Thank you.
Alexis Wilke

Comments

AlexisWilke’s picture

StatusFileSize
new337 bytes

And here is the actual patch... 8-}

AlexisWilke’s picture

StatusFileSize
new630 bytes

Hmmm.... missed the -du options on the diff!

Status: Needs review » Needs work

The last submitted patch, menu-optimization-7.x.patch, failed testing.

avpaderno’s picture

Title: Menu optimization » Menu and theme optimization
StatusFileSize
new1.22 KB

I re-rolled the patch, which also remove the line $num_items = count($items) from theme_item_list(); the variable is not used in the function.

avpaderno’s picture

Category: bug » task
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 813728_menu_theme_optimization.patch, failed testing.

avpaderno’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 813728_menu_theme_optimization.patch, failed testing.

avpaderno’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB

I apologize for the mistake; theme_item_list() contain the same code contained in menu_tree_output().

The patch is a little optimization of the code; there is no reason to keep evaluating $num_items - 1 in a loop, when that value can be stored in a local variable.

Status: Needs review » Needs work

The last submitted patch, 813728_menu_theme_optimization_corrected.patch, failed testing.

avpaderno’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB

It seems it's not the right day for me to make patches. :-)

I have fixed the patch.

AlexisWilke’s picture

I still don't see why my patch was refused... 8-P

Can we ask the person working on the patch to fix the English? (lastest checkotu, and 0 exception(es), and probably others...)

Thank you.
Alexis

retester2010’s picture

lgpolacchini’s picture

thedavidmeister’s picture

Assigned: AlexisWilke » Unassigned
Issue summary: View changes
Status: Needs review » Closed (won't fix)

I'm not convinced this optimization would result in a measurable performance impact and doesn't improve legibility much either.

I'm going to close this off because d8 does things differently and it's probably not worth pushing to d7 now. Feel free to re-open if you've profiled the patch and can show the performance improvement there.