Mercurial > hg > isophonics-drupal-site
diff core/lib/Drupal/Component/Diff/Engine/DiffEngine.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line diff
--- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php Mon Apr 23 09:46:53 2018 +0100 @@ -201,28 +201,30 @@ 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; + $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; + } } - } - 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; - } - 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 @@ $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 @@ $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 @@ 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 @@ 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 @@ 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]); } } }