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;
|
||||
foreach($active_ctx->mappings as $term => $definition) {
|
||||
// skip terms with colons, they can't be prefixes
|
||||
if(strpos($term, ':') !== false) {
|
||||
if($definition && $definition->_term_has_colon) {
|
||||
continue;
|
||||
}
|
||||
// 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')) {
|
||||
// see if the term has a prefix
|
||||
$colon = strpos($term, ':');
|
||||
if($colon !== false) {
|
||||
if($mapping->_term_has_colon) {
|
||||
$prefix = substr($term, 0, $colon);
|
||||
if(property_exists($local_ctx, $prefix)) {
|
||||
// define parent prefix
|
||||
|
|
Loading…
Reference in a new issue