I was doing some code profiling with XHPROF and noticed that nodequeue makes some resource expensive calls to three particular functions:
nodequeue_get_subqueues_by_node
nodequeue_load_subqueues_by_reference
smartqueue_taxonomy_nodequeue_subqueues
A static cache provides a cache for multiple calls to the functions within the same page request, something that can happen literally 100's of times during XHPROF testing (see attached screenshot)
Looking into it further I noticed that there was no usage of a static cache, or if it was used it was not actually set.
The attached patch provides a static cache for those functions, please review and adjust if needed.
Thanks.
Comments
Comment #1
fizk commentedComment #2
fizk commentedThanks for the patch! Why did you remove the use of
drupal_static?Comment #3
fizk commentedTriggering automated tests.
Comment #4
fizk commentedTriggering automated tests.
Comment #8
davidwhthomas commentedThanks fizk!
Actually yeah, should be fine to use the drupal_static central cache there
$cache = &drupal_static(__FUNCTION__, array());Maybe was removed as didn't appear a need to clear the central cache for that function from other places, more of a private static cache.
Cheers,
David