Added optimization to avoid extra bnode sorting.
This commit is contained in:
parent
ff35e9796f
commit
af25c067de
32
jsonld.php
32
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)
|
||||||
{
|
{
|
||||||
usort($bnodes, array($this, 'deepCompareBlankNodes'));
|
if($resort)
|
||||||
|
{
|
||||||
|
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,20 +1927,24 @@ class JsonLdProcessor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only keep non-canonically named bnodes
|
// only clear serializations if resorting is necessary
|
||||||
$tmp = $bnodes;
|
if($resort)
|
||||||
$bnodes = array();
|
|
||||||
foreach($tmp as $i => $b)
|
|
||||||
{
|
{
|
||||||
$iriB = $b->{'@subject'}->{'@iri'};
|
// only keep non-canonically named bnodes
|
||||||
if(!$c14n->inNamespace($iriB))
|
$tmp = $bnodes;
|
||||||
|
$bnodes = array();
|
||||||
|
foreach($tmp as $i => $b)
|
||||||
{
|
{
|
||||||
// mark serializations related to the named bnodes as dirty
|
$iriB = $b->{'@subject'}->{'@iri'};
|
||||||
foreach($renamed as $r)
|
if(!$c14n->inNamespace($iriB))
|
||||||
{
|
{
|
||||||
$this->markSerializationDirty($iriB, $r, $dir);
|
// mark serializations related to the named bnodes as dirty
|
||||||
|
foreach($renamed as $r)
|
||||||
|
{
|
||||||
|
$this->markSerializationDirty($iriB, $r, $dir);
|
||||||
|
}
|
||||||
|
$bnodes[] = $b;
|
||||||
}
|
}
|
||||||
$bnodes[] = $b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue