forked from friendica/php-json-ld
Add optimization that caches presence of colon in term.
This commit is contained in:
parent
1abb809e8e
commit
9759c9340d
10
jsonld.php
10
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
|
||||||
|
@ -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