Added optimization to avoid extra bnode sorting.

This commit is contained in:
Dave Longley 2011-11-09 13:02:18 -05:00
parent ff35e9796f
commit af25c067de
1 changed files with 21 additions and 11 deletions

View File

@ -1884,13 +1884,19 @@ class JsonLdProcessor
}
// keep sorting and naming blank nodes until they are all named
$resort = true;
while(count($bnodes) > 0)
{
if($resort)
{
usort($bnodes, array($this, 'deepCompareBlankNodes'));
}
// name all bnodes according to the first bnode's relation mappings
// (if it has mappings then a resort will be necessary)
$bnode = array_shift($bnodes);
$iri = $bnode->{'@subject'}->{'@iri'};
$resort = ($this->serializations->$iri->{'props'} !== null);
$dirs = array('props', 'refs');
foreach($dirs as $dir)
{
@ -1921,6 +1927,9 @@ class JsonLdProcessor
}
}
// only clear serializations if resorting is necessary
if($resort)
{
// only keep non-canonically named bnodes
$tmp = $bnodes;
$bnodes = array();
@ -1939,6 +1948,7 @@ class JsonLdProcessor
}
}
}
}
// sort property lists that now have canonically-named bnodes
foreach($edges->props as $key => $value)