From 70f5c02d47818c8ea033984b39d26988771dca45 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 8 Apr 2018 20:38:21 +0100 Subject: [PATCH] Use non-nestable values as keys for O(1) lookup --- Parsedown.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Parsedown.php b/Parsedown.php index f7d0a27..62cbf5a 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -1114,6 +1114,8 @@ class Parsedown { $Elements = array(); + $nonNestables = array_combine($nonNestables, $nonNestables); + # $excerpt is based on the first occurrence of a marker while ($excerpt = strpbrk($text, $this->inlineMarkerList)) @@ -1128,7 +1130,7 @@ class Parsedown { # check to see if the current inline type is nestable in the current context - if ( ! empty($nonNestables) and in_array($inlineType, $nonNestables)) + if (isset($nonNestables[$inlineType])) { continue; }