Add optimization that caches presence of colon in term.

This commit is contained in:
Dave Longley 2016-04-23 22:39:08 -04:00
parent 1abb809e8e
commit 9759c9340d
1 changed files with 8 additions and 4 deletions

View File

@ -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