Skip to content

Fixed BaseArray class name #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# [2.0.3](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.3) (2016-07-18)

* Fixed `BaseArray` class name
* Fixed `SequenceMatcher::getMatchingBlocks`

# [2.0.2](https://github.com/phalcongelist/php-diff/releases/tag/v2.0.2) (2016-07-18)

* Fixed Renderer namespace
* Fixed `Renderer` namespace

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

* Fixed Composer autoload namespace
* Adding a CONTRIBUTING file
* Adding a `CONTRIBUTING.md` file

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

Expand Down
File renamed without changes.
34 changes: 14 additions & 20 deletions src/Diff/SequenceMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function setOptions(array $options)
public function setSequences($a, $b)
{
$this->setSeq1($a)
->setSeq2($b);
->setSeq2($b);

return $this;
}
Expand Down Expand Up @@ -284,31 +284,31 @@ public function findLongestMatch($alo, $ahi, $blo, $bhi)
while ($bestI > $alo && $bestJ > $blo && !$this->isBJunk($b[$bestJ - 1]) &&
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)
) {
--$bestI;
--$bestJ;
++$bestSize;
--$bestI;
--$bestJ;
++$bestSize;
}

while ($bestI + $bestSize < $ahi &&
($bestJ + $bestSize) < $bhi &&
!$this->isBJunk($b[$bestJ + $bestSize]) &&
!$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)
) {
++$bestSize;
++$bestSize;
}

while ($bestI > $alo && $bestJ > $blo && $this->isBJunk($b[$bestJ - 1]) &&
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)) {
--$bestI;
--$bestJ;
++$bestSize;
!$this->linesAreDifferent($bestI - 1, $bestJ - 1)) {
--$bestI;
--$bestJ;
++$bestSize;
}

while ($bestI + $bestSize < $ahi &&
$bestJ + $bestSize < $bhi && $this->isBJunk($b[$bestJ + $bestSize]) &&
!$this->linesAreDifferent($bestI + $bestSize, $bestJ + $bestSize)
) {
++$bestSize;
++$bestSize;
}

return [
Expand Down Expand Up @@ -367,16 +367,9 @@ public function getMatchingBlocks()
$aLength = count($this->a);
$bLength = count($this->b);

$queue = [
[
0,
$aLength,
0,
$bLength
]
];

$queue = [[0, $aLength, 0, $bLength]];
$matchingBlocks = [];

while (!empty($queue)) {
list ($alo, $ahi, $blo, $bhi) = array_pop($queue);
$x = $this->findLongestMatch($alo, $ahi, $blo, $bhi);
Expand Down Expand Up @@ -408,7 +401,8 @@ public function getMatchingBlocks()
$i1 = 0;
$j1 = 0;
$k1 = 0;
$nonAdjacent = [$this, 'tupleSort'];
$nonAdjacent = [];

foreach ($matchingBlocks as $block) {
list ($i2, $j2, $k2) = $block;

Expand Down