From 149f92896345b1fd873a814721b6e042a8681593 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 28 Nov 2006 16:34:28 +0000 Subject: begin working on getting this thing a bit faster. I need to finish the other calls, this commit actually will break the diff engine and the updater. The speed increase noticed is from 89 seconds to 22 seconds as well as saving a lot of memory. git-svn-id: file:///svn/phpbb/trunk@6692 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/diff.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/diff/diff.php') diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index ca8d16fd3e..59124ae7ef 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -46,10 +46,17 @@ class diff * @param array $from_lines An array of strings. Typically these are lines from a file. * @param array $to_lines An array of strings. */ - function diff($from_lines, $to_lines) + function diff(&$from_content, &$to_content) { $diff_engine = &new diff_engine(); - $this->_edits = call_user_func_array(array($diff_engine, 'diff'), array($from_lines, $to_lines)); + + $match = array('#\r\n?#', "#([\n]+){2,}#u"); + $replace = array("\n", "\n"); + + $from_content = preg_replace($match, $replace, $from_content); + $to_content = preg_replace($match, $replace, $to_content); + + $this->_edits = call_user_func_array(array($diff_engine, 'diff'), array(explode("\n", $from_content), explode("\n", $to_content))); } /** -- cgit v1.2.1 From d417d53c0aceb79f18df31a372f78f9dc44519c7 Mon Sep 17 00:00:00 2001 From: David M Date: Wed, 29 Nov 2006 01:33:14 +0000 Subject: better regex git-svn-id: file:///svn/phpbb/trunk@6694 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/diff.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/diff/diff.php') diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index 59124ae7ef..430ae0f522 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -50,11 +50,8 @@ class diff { $diff_engine = &new diff_engine(); - $match = array('#\r\n?#', "#([\n]+){2,}#u"); - $replace = array("\n", "\n"); - - $from_content = preg_replace($match, $replace, $from_content); - $to_content = preg_replace($match, $replace, $to_content); + $from_content = preg_replace('#[\n\r]+#', "\n", $from_content); + $to_content = preg_replace('#[\n\r]+#', "\n", $to_content); $this->_edits = call_user_func_array(array($diff_engine, 'diff'), array(explode("\n", $from_content), explode("\n", $to_content))); } -- cgit v1.2.1 From 7ed41c4de14e5b454e8935c35edef4a0b3c400a9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 29 Nov 2006 15:51:54 +0000 Subject: updates for the updater and the diff engine. - this update also includes an important change for including the diff engine, since we may need to include an updated engine before updating. This basically means that for a future update (B4 to another version) requires copying the new diff files first... the new include method should prevent this needed handwork for later versions then. git-svn-id: file:///svn/phpbb/trunk@6695 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/diff/diff.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'phpBB/includes/diff/diff.php') diff --git a/phpBB/includes/diff/diff.php b/phpBB/includes/diff/diff.php index 430ae0f522..b18970dab4 100644 --- a/phpBB/includes/diff/diff.php +++ b/phpBB/includes/diff/diff.php @@ -15,10 +15,6 @@ if (!defined('IN_PHPBB')) exit; } -// Include renderer and engine -include_once($phpbb_root_path . 'includes/diff/engine.' . $phpEx); -include_once($phpbb_root_path . 'includes/diff/renderer.' . $phpEx); - /** * Code from pear.php.net, Text_Diff-0.2.1 (beta) package * http://pear.php.net/package/Text_Diff/ @@ -46,14 +42,10 @@ class diff * @param array $from_lines An array of strings. Typically these are lines from a file. * @param array $to_lines An array of strings. */ - function diff(&$from_content, &$to_content) + function diff(&$from_content, &$to_content, $preserve_cr = true) { $diff_engine = &new diff_engine(); - - $from_content = preg_replace('#[\n\r]+#', "\n", $from_content); - $to_content = preg_replace('#[\n\r]+#', "\n", $to_content); - - $this->_edits = call_user_func_array(array($diff_engine, 'diff'), array(explode("\n", $from_content), explode("\n", $to_content))); + $this->_edits = $diff_engine->diff($from_content, $to_content, $preserve_cr); } /** @@ -252,7 +244,7 @@ class mapped_diff extends diff * compared when computing the diff. * @param array $mapped_to_lines This array should have the same number of elements as $to_lines. */ - function mapped_diff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) + function mapped_diff(&$from_lines, &$to_lines, &$mapped_from_lines, &$mapped_to_lines) { if (sizeof($from_lines) != sizeof($mapped_from_lines) || sizeof($to_lines) != sizeof($mapped_to_lines)) { @@ -418,10 +410,16 @@ class diff3 extends diff * @param array $final1 The first version to compare to. * @param array $final2 The second version to compare to. */ - function diff3($orig, $final1, $final2) + function diff3(&$orig, &$final1, &$final2) { - $engine = new diff_engine(); - $this->_edits = $this->_diff3($engine->diff($orig, $final1), $engine->diff($orig, $final2)); + $diff_engine = &new diff_engine(); + + $diff_1 = $diff_engine->diff($orig, $final1); + $diff_2 = $diff_engine->diff($orig, $final2); + + unset($engine); + + $this->_edits = $this->_diff3($diff_1, $diff_2); } /** @@ -546,7 +544,7 @@ class diff3 extends diff /** * @access private */ - function _diff3($edits1, $edits2) + function _diff3(&$edits1, &$edits2) { $edits = array(); $bb = &new diff3_block_builder(); -- cgit v1.2.1