Added optimization to avoid extra bnode sorting.
This commit is contained in:
parent
ff35e9796f
commit
af25c067de
1 changed files with 21 additions and 11 deletions
10
jsonld.php
10
jsonld.php
|
@ -1884,13 +1884,19 @@ class JsonLdProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep sorting and naming blank nodes until they are all named
|
// keep sorting and naming blank nodes until they are all named
|
||||||
|
$resort = true;
|
||||||
while(count($bnodes) > 0)
|
while(count($bnodes) > 0)
|
||||||
|
{
|
||||||
|
if($resort)
|
||||||
{
|
{
|
||||||
usort($bnodes, array($this, 'deepCompareBlankNodes'));
|
usort($bnodes, array($this, 'deepCompareBlankNodes'));
|
||||||
|
}
|
||||||
|
|
||||||
// name all bnodes according to the first bnode's relation mappings
|
// 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);
|
$bnode = array_shift($bnodes);
|
||||||
$iri = $bnode->{'@subject'}->{'@iri'};
|
$iri = $bnode->{'@subject'}->{'@iri'};
|
||||||
|
$resort = ($this->serializations->$iri->{'props'} !== null);
|
||||||
$dirs = array('props', 'refs');
|
$dirs = array('props', 'refs');
|
||||||
foreach($dirs as $dir)
|
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
|
// only keep non-canonically named bnodes
|
||||||
$tmp = $bnodes;
|
$tmp = $bnodes;
|
||||||
$bnodes = array();
|
$bnodes = array();
|
||||||
|
@ -1939,6 +1948,7 @@ class JsonLdProcessor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// sort property lists that now have canonically-named bnodes
|
// sort property lists that now have canonically-named bnodes
|
||||||
foreach($edges->props as $key => $value)
|
foreach($edges->props as $key => $value)
|
||||||
|
|
Loading…
Reference in a new issue