X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Flib%2FDrupal%2FComponent%2FDiff%2FEngine%2FDiffEngine.php;fp=web%2Fcore%2Flib%2FDrupal%2FComponent%2FDiff%2FEngine%2FDiffEngine.php;h=27b0f325724b09ba31deb109af71a2086c0db250;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=b56aa99aa7ca43b438c4712b0a1b64ee5b273537;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/web/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php b/web/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php index b56aa99aa..27b0f3257 100644 --- a/web/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php +++ b/web/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php @@ -201,28 +201,30 @@ class DiffEngine { continue; } $matches = $ymatches[$line]; - reset($matches); - while (list ($junk, $y) = each($matches)) { - if (empty($this->in_seq[$y])) { - $k = $this->_lcs_pos($y); - $this::USE_ASSERTS && assert($k > 0); - $ymids[$k] = $ymids[$k - 1]; - break; - } - } - while (list ($junk, $y) = each($matches)) { - if ($y > $this->seq[$k - 1]) { - $this::USE_ASSERTS && assert($y < $this->seq[$k]); - // Optimization: this is a common case: - // next match is just replacing previous match. - $this->in_seq[$this->seq[$k]] = FALSE; - $this->seq[$k] = $y; - $this->in_seq[$y] = 1; + $found_empty = FALSE; + foreach ($matches as $y) { + if (!$found_empty) { + if (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + $this::USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k - 1]; + $found_empty = TRUE; + } } - elseif (empty($this->in_seq[$y])) { - $k = $this->_lcs_pos($y); - $this::USE_ASSERTS && assert($k > 0); - $ymids[$k] = $ymids[$k - 1]; + else { + if ($y > $this->seq[$k - 1]) { + $this::USE_ASSERTS && assert($y < $this->seq[$k]); + // Optimization: this is a common case: + // next match is just replacing previous match. + $this->in_seq[$this->seq[$k]] = FALSE; + $this->seq[$k] = $y; + $this->in_seq[$y] = 1; + } + elseif (empty($this->in_seq[$y])) { + $k = $this->_lcs_pos($y); + $this::USE_ASSERTS && assert($k > 0); + $ymids[$k] = $ymids[$k - 1]; + } } } } @@ -343,7 +345,7 @@ class DiffEngine { $i = 0; $j = 0; - $this::USE_ASSERTS && assert('sizeof($lines) == sizeof($changed)'); + $this::USE_ASSERTS && assert(sizeof($lines) == sizeof($changed)); $len = sizeof($lines); $other_len = sizeof($other_changed); @@ -363,7 +365,7 @@ class DiffEngine { $j++; } while ($i < $len && !$changed[$i]) { - $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]); $i++; $j++; while ($j < $other_len && $other_changed[$j]) { @@ -399,11 +401,11 @@ class DiffEngine { while ($start > 0 && $changed[$start - 1]) { $start--; } - $this::USE_ASSERTS && assert('$j > 0'); + $this::USE_ASSERTS && assert($j > 0); while ($other_changed[--$j]) { continue; } - $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]); } /* @@ -426,7 +428,7 @@ class DiffEngine { while ($i < $len && $changed[$i]) { $i++; } - $this::USE_ASSERTS && assert('$j < $other_len && ! $other_changed[$j]'); + $this::USE_ASSERTS && assert($j < $other_len && ! $other_changed[$j]); $j++; if ($j < $other_len && $other_changed[$j]) { $corresponding = $i; @@ -444,11 +446,11 @@ class DiffEngine { while ($corresponding < $i) { $changed[--$start] = 1; $changed[--$i] = 0; - $this::USE_ASSERTS && assert('$j > 0'); + $this::USE_ASSERTS && assert($j > 0); while ($other_changed[--$j]) { continue; } - $this::USE_ASSERTS && assert('$j >= 0 && !$other_changed[$j]'); + $this::USE_ASSERTS && assert($j >= 0 && !$other_changed[$j]); } } }