Attached patch adds caching for the results of all *_load_all() functions.
Panels executes these functions multiple times without an argument on a single page request, so by statically caching the results, this is a noticeable performance improvement.

I didn't cache the results of panels_page_load_all(), since that is usually invoked only once per request.

oh wait... latest dev already includes something like that. However, that contains some bugs.

Comments

merlinofchaos’s picture

No patch attached.

sun’s picture

StatusFileSize
new12.49 KB

Fixes:

- Variable spelling mistake in panels_views_load_all()
- Use isset() instead of array_key_exists(), which is cleaner and faster
- Use early-outs instead of indented function bodys.

merlinofchaos’s picture

array_key_exists is used why:

$array = array();

isset($array['var']) == FALSE;
array_key_exists('var', $array) == FALSE;

$array['var'] = NULL;

isset($array['var']) == FALSE;
array_key_exists('var', $array) == TRUE;

This prevents it from trying to recache panels it did not find.

sun’s picture

StatusFileSize
new12.54 KB

Reverted isset() to array_key_exists() where required.

sun’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new12.46 KB

Re-rolled patch.

Contains only coding-style fixes now, thus RTBC.

pancho’s picture

Title: Cache results of *_load_all() functions » Codestyle: use early-outs for *_load and *_load_all
Version: 5.x-2.0-beta4b » 5.x-2.x-dev
Status: Reviewed & tested by the community » Fixed

The patch did contain more than coding-style fixes: in panels_mini_load_all(), isset() is replaced by array_key_exists(). This is correct though. Nice stuff, thanks!

If you had separated out the variable spelling mistake in panels_views_load_all() as a critical bug, I would have found it and saved some time...

Tested and committed: http://drupal.org/cvs?commit=119623

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.