optimize LinkManagement a little
authorDenis Ovsienko <denis@ovsienko.info>
Tue, 4 Jul 2017 14:34:21 +0000 (15:34 +0100)
committerDenis Ovsienko <denis@ovsienko.info>
Tue, 4 Jul 2017 14:44:00 +0000 (15:44 +0100)
Do not load some data structures that are not involved in the
processing. For a particular object in my data set this lowers the page
generation time by 10 times and memory footprint as observed with
memory_get_peak_usage() by 2 times.

LinkManagement/plugins/linkmgmt.php

index 1e54093..4e54be4 100644 (file)
@@ -195,21 +195,13 @@ class linkchain_cache
 
                        if($object['IPV4OBJ'])
                        {
-                               // ip addresses
-                               //amplifyCell($object); /* get ports, ipv4, ipv6, nat4 and files */
-                               $object['ipv4'] = getObjectIPv4Allocations ($object_id);
                                $object['portip'] = array();
-                               foreach($object['ipv4'] as $ipv4)
+                               foreach(getObjectIPv4Allocations ($object_id) as $ipv4)
                                {
                                        $object['portip'][$ipv4['osif']] = $ipv4['addrinfo']['ip'];
                                }
                        }
 
-                       if($object['container_id'])
-                       {
-                               $container = $this->getobject($object['container_id']);
-                       }
-
                        $this->cache['o'.$object_id] = $object;
                }
                else
@@ -3333,10 +3325,8 @@ class linkmgmt_gvmap {
 
                                $object = spotEntity ('object', $object_id);
 
-                               // ip addresses
-                               amplifyCell($object);
                                $object['portip'] = array();
-                               foreach($object['ipv4'] as $ipv4)
+                               foreach(getObjectIPv4Allocations ($object_id) as $ipv4)
                                {
                                        $object['portip'][$ipv4['osif']] = $ipv4['addrinfo']['ip'];
                                }