Possible code improvement, performance
-
File: /lib/Advman/Dal.php
Line: 43 (approx)These lines if never propagated with a value, default to an empty value, that always forces a save of an empty value, which will be updated next time with another empty value.
Essentially adding unnecessary load or in my case 0.5 seconds, which could be avoided.
# This code always wants to save
// Get networks data $d = get_option('plugin_advman_networks'); if (empty($d)) { $d = array(); $save = true; } $data['networks'] = $d;
# Save functions (update_option) are expensive in terms of load, causing the 0.5s lag
if ($save) { update_option('plugin_advman_settings', $data['settings']); update_option('plugin_advman_ads', $data['ads']); update_option('plugin_advman_networks', $data['networks']); update_option('plugin_advman_stats', $data['stats']); }
# In my case I made it ignore empty arrays. I also moved the update_options in to the actually save trigger, as it was calling update_option 4 times when just the stats were updated, thus 3 times not needed.
// Get networks data $d = get_option('plugin_advman_networks'); if (empty($d) && !is_array($d)) { $d = array(); update_option('plugin_advman_networks', $d); } $data['networks'] = $d;
Hope that helps, let me know if I can help more.
- The topic ‘Possible code improvement, performance’ is closed to new replies.