Performance/reliability improvement for leaving unrecognised tags.

error_behaviour = self::LEAVE is the default behaviour. In this case,
we don’t even need to bother recognising such tags. Rather than
replacing with marker images and re-inserting the original text after
we’re done, we can leave them alone.

This should make the code faster and more reliable.
This commit is contained in:
Sam Minnee 2015-06-22 11:31:12 +01:00
parent 6d05c57881
commit d7241958ff

View File

@ -321,6 +321,17 @@ class ShortcodeParser extends Object {
}
}
// Step 3: remove any tags that don't have handlers registered
// Only do this if self::$error_behavior == self::LEAVE
// This is optional but speeds things up.
if(self::$error_behavior == self::LEAVE) {
foreach($tags as $i => $tag) {
if(empty($this->shortcodes[$tag['open']])) {
unset($tags[$i]);
}
}
}
return array_values($tags);
}