From c8a1bb314dda2a157b972ff0bc633bbb5d2e271c Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Thu, 31 May 2018 12:38:41 +1200 Subject: [PATCH] Refactor difflib to not use each() --- thirdparty/difflib/difflib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/thirdparty/difflib/difflib.php b/thirdparty/difflib/difflib.php index b75a4feee..b66e7d761 100644 --- a/thirdparty/difflib/difflib.php +++ b/thirdparty/difflib/difflib.php @@ -283,14 +283,16 @@ class DiffEngine continue; $matches = $ymatches[$line]; reset($matches); + $pointer = 0; foreach ($matches as $y) + $pointer++; if (empty($this->in_seq[$y])) { $k = $this->lcs_pos($y); assert($k > 0); $ymids[$k] = $ymids[$k - 1]; break; } - foreach ($matches as $y) { + foreach (array_slice($matches, $pointer) as $y) { if ($y > $this->seq[$k - 1]) { assert($y < $this->seq[$k]); // Optimization: this is a common case: