mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
Performance enhancement for impact analysis: avoid looping in the recursion.
SVN:trunk[2505]
This commit is contained in:
@@ -55,6 +55,8 @@ function AddNodeDetails(&$oNode, $oObj)
|
||||
$oNode->SetAttribute('zlist', implode(',', $aLabels));
|
||||
}
|
||||
|
||||
$G_aCachedObjects = array();
|
||||
|
||||
/**
|
||||
* Get the related objects through the given relation, output in XML
|
||||
* @param DBObject $oObj The current object
|
||||
@@ -62,10 +64,23 @@ function AddNodeDetails(&$oNode, $oObj)
|
||||
*/
|
||||
function GetRelatedObjectsAsXml(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode, $iDepth = 0, $aExcludedClasses)
|
||||
{
|
||||
global $G_aCachedObjects;
|
||||
$aResults = array();
|
||||
$bAddLinks = false;
|
||||
$oObj->GetRelatedObjects($sRelationName, 1 /* iMaxDepth */, $aResults);
|
||||
|
||||
if ($iDepth > MAX_RECURSION_DEPTH) return;
|
||||
|
||||
$sIdxKey = get_class($oObj).':'.$oObj->GetKey();
|
||||
if (!array_key_exists($sIdxKey, $G_aCachedObjects))
|
||||
{
|
||||
$oObj->GetRelatedObjects($sRelationName, 1 /* iMaxDepth */, $aResults);
|
||||
$G_aCachedObjects[$sIdxKey] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
//$aResults = $G_aCachedObjects[$sIdxKey];
|
||||
}
|
||||
|
||||
foreach($aResults as $sRelatedClass => $aObjects)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user