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
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 813728_menu_theme_optimization_fixed.patch | 1.61 KB | avpaderno |
| #10 | 813728_menu_theme_optimization_corrected.patch | 1.61 KB | avpaderno |
| #4 | 813728_menu_theme_optimization.patch | 1.22 KB | avpaderno |
| #2 | menu-optimization-7.x.patch | 630 bytes | AlexisWilke |
| #1 | menu-optimization-7.x.patch | 337 bytes | AlexisWilke |
Comments
Comment #1
AlexisWilke commentedAnd here is the actual patch... 8-}
Comment #2
AlexisWilke commentedHmmm.... missed the -du options on the diff!
Comment #4
avpadernoI re-rolled the patch, which also remove the line
$num_items = count($items)fromtheme_item_list(); the variable is not used in the function.Comment #6
avpadernoComment #8
avpaderno#4: 813728_menu_theme_optimization.patch queued for re-testing.
Comment #10
avpadernoI apologize for the mistake;
theme_item_list()contain the same code contained inmenu_tree_output().The patch is a little optimization of the code; there is no reason to keep evaluating
$num_items - 1in a loop, when that value can be stored in a local variable.Comment #12
avpadernoIt seems it's not the right day for me to make patches. :-)
I have fixed the patch.
Comment #13
AlexisWilke commentedI 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
Comment #14
retester2010 commented#12: 813728_menu_theme_optimization_fixed.patch queued for re-testing.
Comment #15
lgpolacchini commented#12: 813728_menu_theme_optimization_fixed.patch queued for re-testing.
Comment #16
thedavidmeister commentedI'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.