Skip to content

Commit cce4029

Browse files
authored
Merge pull request #5 from phalcongelist/2.0.x
Fixed BaseArray class name
2 parents 505d5ed + e796d8d commit cce4029

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

CHANGELOG.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
# [2.0.3](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.3) (2016-07-18)
2+
3+
* Fixed `BaseArray` class name
4+
* Fixed `SequenceMatcher::getMatchingBlocks`
5+
16
# [2.0.2](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.2) (2016-07-18)
27

3-
* Fixed Renderer namespace
8+
* Fixed `Renderer` namespace
49

510
# [2.0.1](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.1) (2016-07-18)
611

712
* Fixed Composer autoload namespace
8-
* Adding a CONTRIBUTING file
13+
* Adding a `CONTRIBUTING.md` file
914

1015
# [2.0.0](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.0) (2016-07-17)
1116

File renamed without changes.

src/Diff/SequenceMatcher.php

+14-20
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function setOptions(array $options)
113113
public function setSequences($a, $b)
114114
{
115115
$this->setSeq1($a)
116-
->setSeq2($b);
116+
->setSeq2($b);
117117

118118
return $this;
119119
}
@@ -284,31 +284,31 @@ public function findLongestMatch($alo, $ahi, $blo, $bhi)
284284
while ($bestI > $alo && $bestJ > $blo && !$this->isBJunk($b[$bestJ - 1]) &&
285285
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)
286286
) {
287-
--$bestI;
288-
--$bestJ;
289-
++$bestSize;
287+
--$bestI;
288+
--$bestJ;
289+
++$bestSize;
290290
}
291291

292292
while ($bestI + $bestSize < $ahi &&
293293
($bestJ + $bestSize) < $bhi &&
294294
!$this->isBJunk($b[$bestJ + $bestSize]) &&
295295
!$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)
296296
) {
297-
++$bestSize;
297+
++$bestSize;
298298
}
299299

300300
while ($bestI > $alo && $bestJ > $blo && $this->isBJunk($b[$bestJ - 1]) &&
301-
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)) {
302-
--$bestI;
303-
--$bestJ;
304-
++$bestSize;
301+
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)) {
302+
--$bestI;
303+
--$bestJ;
304+
++$bestSize;
305305
}
306306

307307
while ($bestI + $bestSize < $ahi &&
308308
$bestJ + $bestSize < $bhi && $this->isBJunk($b[$bestJ + $bestSize]) &&
309309
!$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)
310310
) {
311-
++$bestSize;
311+
++$bestSize;
312312
}
313313

314314
return [
@@ -367,16 +367,9 @@ public function getMatchingBlocks()
367367
$aLength = count($this->a);
368368
$bLength = count($this->b);
369369

370-
$queue = [
371-
[
372-
0,
373-
$aLength,
374-
0,
375-
$bLength
376-
]
377-
];
378-
370+
$queue = [[0, $aLength, 0, $bLength]];
379371
$matchingBlocks = [];
372+
380373
while (!empty($queue)) {
381374
list ($alo, $ahi, $blo, $bhi) = array_pop($queue);
382375
$x = $this->findLongestMatch($alo, $ahi, $blo, $bhi);
@@ -408,7 +401,8 @@ public function getMatchingBlocks()
408401
$i1 = 0;
409402
$j1 = 0;
410403
$k1 = 0;
411-
$nonAdjacent = [$this, 'tupleSort'];
404+
$nonAdjacent = [];
405+
412406
foreach ($matchingBlocks as $block) {
413407
list ($i2, $j2, $k2) = $block;
414408

0 commit comments

Comments
 (0)