From: Boris Nagaev Date: Thu, 2 May 2013 14:33:15 +0000 (+0400) Subject: DairikiDiff: Optimise method WordLevelDiff._split() X-Git-Tag: 1.31.0-rc.0~19650 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=c3a13553fa9375f51dea8364d7feb4a85b0e0805;p=lhc%2Fweb%2Fwiklou.git DairikiDiff: Optimise method WordLevelDiff._split() _split() copied two arrays N times, where N is number of lines in diff. This was done by $a = array_merge($a, ...); Instead of doing this, new words are appended to the end of array using []= syntax. Bug: 47989 Change-Id: I41338a2a82fbc20d7511f4c79581880febeeeea5 --- diff --git a/includes/diff/DairikiDiff.php b/includes/diff/DairikiDiff.php index 4435fc6d3c..174c1d6566 100644 --- a/includes/diff/DairikiDiff.php +++ b/includes/diff/DairikiDiff.php @@ -1284,8 +1284,12 @@ class WordLevelDiff extends MappedDiff { if ( preg_match_all( '/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?: (?!< \n) [^\S\n])? /xs', $line, $m ) ) { - $words = array_merge( $words, $m[0] ); - $stripped = array_merge( $stripped, $m[1] ); + foreach ( $m[0] as $word ) { + $words[] = $word; + } + foreach ( $m[1] as $stripped_word ) { + $stripped[] = $stripped_word; + } } } }