Needs review
Project:
Hierarchical Select Node Reference
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2010 at 04:03 UTC
Updated:
13 Nov 2010 at 04:03 UTC
Guys,
great module. But because its intended to a faster and more organic solution that a multi-step form, we must pay attention to speed and some optimizations.
There are several functions that are repeatedly executed and some do expensive SQL searches. Its good to add some caching system for them.
Inside the main "else" can be faster by adding
static $results = array();
if (!empty($results[$parent])) {
return $results[$parent];
}
before and
$results[$parent] = $children;
after
add the following code just after the "empty($nodereference_path)" check
static $results = array();
if (!empty($results[$nodereference_path][$node->type])) {
return $results[$nodereference_path][$node->type];
}
and dont forget the $results[$nodereference_path][$node->type] = $field; just before the return.
This not a miracle, but saves loads of SQL calls.
regards,
massa