forked from friendica/php-json-ld
Add optimization that caches presence of colon in term.
This commit is contained in:
parent
1abb809e8e
commit
9759c9340d
12
jsonld.php
12
jsonld.php
|
@ -4698,7 +4698,7 @@ class JsonLdProcessor {
|
||||||
$choice = null;
|
$choice = null;
|
||||||
foreach($active_ctx->mappings as $term => $definition) {
|
foreach($active_ctx->mappings as $term => $definition) {
|
||||||
// skip terms with colons, they can't be prefixes
|
// skip terms with colons, they can't be prefixes
|
||||||
if(strpos($term, ':') !== false) {
|
if($definition && $definition->_term_has_colon) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// skip entries with @ids that are not partial matches
|
// skip entries with @ids that are not partial matches
|
||||||
|
@ -4878,7 +4878,7 @@ class JsonLdProcessor {
|
||||||
|
|
||||||
// clear context entry
|
// clear context entry
|
||||||
if($value === null || (is_object($value) &&
|
if($value === null || (is_object($value) &&
|
||||||
self::_hasKeyValue($value, '@id', null))) {
|
self::_hasKeyValue($value, '@id', null))) {
|
||||||
$active_ctx->mappings->{$term} = null;
|
$active_ctx->mappings->{$term} = null;
|
||||||
$defined->{$term} = true;
|
$defined->{$term} = true;
|
||||||
return;
|
return;
|
||||||
|
@ -4952,10 +4952,14 @@ class JsonLdProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always compute whether term has a colon as an optimization for
|
||||||
|
// _compactIri
|
||||||
|
$colon = strpos($term, ':');
|
||||||
|
$mapping->_term_has_colon = ($colon !== false);
|
||||||
|
|
||||||
if(!property_exists($mapping, '@id')) {
|
if(!property_exists($mapping, '@id')) {
|
||||||
// see if the term has a prefix
|
// see if the term has a prefix
|
||||||
$colon = strpos($term, ':');
|
if($mapping->_term_has_colon) {
|
||||||
if($colon !== false) {
|
|
||||||
$prefix = substr($term, 0, $colon);
|
$prefix = substr($term, 0, $colon);
|
||||||
if(property_exists($local_ctx, $prefix)) {
|
if(property_exists($local_ctx, $prefix)) {
|
||||||
// define parent prefix
|
// define parent prefix
|
||||||
|
|
Loading…
Reference in a new issue