Made sort optimization more effective.
This commit is contained in:
parent
af25c067de
commit
7e65429375
30
jsonld.php
30
jsonld.php
|
@ -1889,6 +1889,7 @@ class JsonLdProcessor
|
||||||
{
|
{
|
||||||
if($resort)
|
if($resort)
|
||||||
{
|
{
|
||||||
|
$resort = false;
|
||||||
usort($bnodes, array($this, 'deepCompareBlankNodes'));
|
usort($bnodes, array($this, 'deepCompareBlankNodes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1927,24 +1928,24 @@ class JsonLdProcessor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only clear serializations if resorting is necessary
|
// only keep non-canonically named bnodes
|
||||||
if($resort)
|
$tmp = $bnodes;
|
||||||
|
$bnodes = array();
|
||||||
|
foreach($tmp as $i => $b)
|
||||||
{
|
{
|
||||||
// only keep non-canonically named bnodes
|
$iriB = $b->{'@subject'}->{'@iri'};
|
||||||
$tmp = $bnodes;
|
if(!$c14n->inNamespace($iriB))
|
||||||
$bnodes = array();
|
|
||||||
foreach($tmp as $i => $b)
|
|
||||||
{
|
{
|
||||||
$iriB = $b->{'@subject'}->{'@iri'};
|
// mark serializations related to the named bnodes as dirty
|
||||||
if(!$c14n->inNamespace($iriB))
|
foreach($renamed as $r)
|
||||||
{
|
{
|
||||||
// mark serializations related to the named bnodes as dirty
|
if($this->markSerializationDirty($iriB, $r, $dir))
|
||||||
foreach($renamed as $r)
|
|
||||||
{
|
{
|
||||||
$this->markSerializationDirty($iriB, $r, $dir);
|
// resort if a serialization was marked dirty
|
||||||
|
$resort = true;
|
||||||
}
|
}
|
||||||
$bnodes[] = $b;
|
|
||||||
}
|
}
|
||||||
|
$bnodes[] = $b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1974,14 +1975,19 @@ class JsonLdProcessor
|
||||||
* @param iri the IRI of the bnode to check.
|
* @param iri the IRI of the bnode to check.
|
||||||
* @param changed the old IRI of the bnode that changed.
|
* @param changed the old IRI of the bnode that changed.
|
||||||
* @param dir the direction to check ('props' or 'refs').
|
* @param dir the direction to check ('props' or 'refs').
|
||||||
|
*
|
||||||
|
* @return true if the serialization was marked dirty, false if not.
|
||||||
*/
|
*/
|
||||||
public function markSerializationDirty($iri, $changed, $dir)
|
public function markSerializationDirty($iri, $changed, $dir)
|
||||||
{
|
{
|
||||||
|
$rval = false;
|
||||||
$s = $this->serializations->$iri;
|
$s = $this->serializations->$iri;
|
||||||
if($s->$dir !== null and property_exists($s->$dir->m, $changed))
|
if($s->$dir !== null and property_exists($s->$dir->m, $changed))
|
||||||
{
|
{
|
||||||
$s->$dir = null;
|
$s->$dir = null;
|
||||||
|
$rval = true;
|
||||||
}
|
}
|
||||||
|
return $rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue