From b7d5b07ce41fbf5f6b613de46ecd61359fef492f Mon Sep 17 00:00:00 2001 From: rurban Date: Mon, 10 May 2004 11:19:15 +0000 Subject: [PATCH] revert premature optimization git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3470 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/InlineParser.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/InlineParser.php b/lib/InlineParser.php index 6e8d808e2..a8ff8fc35 100644 --- a/lib/InlineParser.php +++ b/lib/InlineParser.php @@ -1,5 +1,5 @@ * Copyright (C) 2004 Reini Urban * @@ -144,7 +144,7 @@ class RegexpSet function _match ($text, $regexps, $repeat) { - // certain php builds crash here: + // If one of the regexps is an empty string, php will crash here: // sf.net: Fatal error: Allowed memory size of 8388608 bytes exhausted // (tried to allocate 634 bytes) @@ -178,12 +178,15 @@ class RegexpSet if (count($matched) > 2) { // We could do much better, if we would know the matching markup for the // longest regexp match: - //$hugepat= "/ ( . $repeat ) ( (" . join(')|(', $regexps) . ") ) /Asx"; - $hugepat= "/ ( . $repeat ) ( (" . join(')|(', array_values($matched)) . ") ) /Asx"; + $hugepat= "/ ( . $repeat ) ( (" . join(')|(', $regexps) . ") ) /Asx"; + // Proposed premature optimization 1: + //$hugepat= "/ ( . $repeat ) ( (" . join(')|(', array_values($matched)) . ") ) /Asx"; if (! preg_match($hugepat, $text, $m)) { return false; } - $match->regexp_ind = $matched_ind[count($m) - 4]; + // Proposed premature optimization 1: + //$match->regexp_ind = $matched_ind[count($m) - 4]; + $match->regexp_ind = count($m) - 4; } else { $match->regexp_ind = $regexp_ind; } -- 2.45.0