Performance enhancement for impact analysis: avoid looping in the recursion.

SVN:trunk[2505]
This commit is contained in:
Denis Flaven
2012-12-05 08:49:38 +00:00
parent 0e3b2a9bf1
commit 0221a65f82

View File

@@ -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)
{