From c3a13553fa9375f51dea8364d7feb4a85b0e0805 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Thu, 2 May 2013 18:33:15 +0400 Subject: [PATCH] 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 --- includes/diff/DairikiDiff.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; + } } } } -- 2.20.1