-
Sub-task
-
Resolution: Fixed
-
Minor
-
2.5
-
MOODLE_25_STABLE
-
MOODLE_25_STABLE
-
- Run unit tests
- Browse around Moodle
- Ensure that no errors are shown and the admin menu works as expected
Inspired by Tim and Sam's work, I've just been having a play with xh_prof.
I noticed that in admin_category we use $this->category_cache to cache records.
This is a protected variable, which is set to an array in the constructor, and also in a purge function. The only operations on it are:
- $this->category_cache = array();
- isset($this->category_cache[$key])
- $this->category_cache[$key] = $value;
- return $this->category_cache[$key];
- while($this->category_cache)
- array_pop($this->category_cache);
In every function which accesses it, we still call is_array($this->category_cache) even though it is only every treated as an array.
On a default install of Moodle with no additional plugins, the locate() function is called around about 8,600 times with up to two is_array() calls.
By removing this, I'm seeing savings of around about 100ms on my laptop.