"psr/http-server-middleware": "^1.0.2",
"psr/log": "^3.0",
"scssphp/scssphp": "^1.11",
- "sebastian/diff": "^5.0.1",
+ "sebastian/diff": "^5.0.3",
"symfony/polyfill-php82": "^1.27.0",
"willdurand/negotiation": "^3.1"
},
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ac72a2546c309a03aa95cb912c9dc966",
+ "content-hash": "2983948012af211bf635948ccf965b06",
"packages": [
{
"name": "cuyz/valinor",
},
{
"name": "sebastian/diff",
- "version": "5.0.1",
+ "version": "5.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02"
+ "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/aae9a0a43bff37bd5d8d0311426c87bf36153f02",
- "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
+ "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
"shasum": ""
},
"require": {
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"security": "https://github.com/sebastianbergmann/diff/security/policy",
- "source": "https://github.com/sebastianbergmann/diff/tree/5.0.1"
+ "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3"
},
"funding": [
{
"type": "github"
}
],
- "time": "2023-03-23T05:12:41+00:00"
+ "time": "2023-05-01T07:48:21+00:00"
},
{
"name": "symfony/css-selector",
},
{
"name": "sebastian/diff",
- "version": "5.0.1",
- "version_normalized": "5.0.1.0",
+ "version": "5.0.3",
+ "version_normalized": "5.0.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02"
+ "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/aae9a0a43bff37bd5d8d0311426c87bf36153f02",
- "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02",
+ "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
+ "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
"shasum": ""
},
"require": {
"phpunit/phpunit": "^10.0",
"symfony/process": "^4.2 || ^5"
},
- "time": "2023-03-23T05:12:41+00:00",
+ "time": "2023-05-01T07:48:21+00:00",
"type": "library",
"extra": {
"branch-alias": {
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"security": "https://github.com/sebastianbergmann/diff/security/policy",
- "source": "https://github.com/sebastianbergmann/diff/tree/5.0.1"
+ "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3"
},
"funding": [
{
'dev_requirement' => false,
),
'sebastian/diff' => array(
- 'pretty_version' => '5.0.1',
- 'version' => '5.0.1.0',
- 'reference' => 'aae9a0a43bff37bd5d8d0311426c87bf36153f02',
+ 'pretty_version' => '5.0.3',
+ 'version' => '5.0.3.0',
+ 'reference' => '912dc2fbe3e3c1e7873313cc801b100b6c68c87b',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/diff',
'aliases' => array(),
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
+## [5.0.3] - 2023-05-01
+
+### Changed
+
+* [#119](https://github.com/sebastianbergmann/diff/pull/119): Improve performance of `TimeEfficientLongestCommonSubsequenceCalculator`
+
+## [5.0.2] - 2023-05-01
+
+### Changed
+
+* [#118](https://github.com/sebastianbergmann/diff/pull/118): Improve performance of `MemoryEfficientLongestCommonSubsequenceCalculator`
+
## [5.0.1] - 2023-03-23
### Fixed
* This component is no longer supported on PHP 5.6
+[5.0.3]: https://github.com/sebastianbergmann/diff/compare/5.0.2...5.0.3
+[5.0.2]: https://github.com/sebastianbergmann/diff/compare/5.0.1...5.0.2
[5.0.1]: https://github.com/sebastianbergmann/diff/compare/5.0.0...5.0.1
[5.0.0]: https://github.com/sebastianbergmann/diff/compare/4.0.4...5.0.0
[4.0.4]: https://github.com/sebastianbergmann/diff/compare/4.0.3...4.0.4
)
)
)
+
+Note: If the chunk size is 0 lines, i.e., `getStartRange()` or `getEndRange()` return 0, the number of line returned by `getStart()` or `getEnd()` is one lower than one would expect. It is the line number after which the chunk should be inserted or deleted; in all other cases, it gives the first line number of the replaced range of lines.
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
-Instead, please send an email to `sebastian@phpunit.de`.
+Instead, please email `sebastian@phpunit.de`.
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
The library that is developed in this repository was either extracted from [PHPUnit](https://github.com/sebastianbergmann/phpunit) or developed specifically as a dependency for PHPUnit.
-The library is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using the library in a HTTP or web context or with untrusted input data is performed. The library might also contain functionality that intentionally exposes internal application data for debugging purposes.
+The library is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using the library in an HTTP or web context or with untrusted input data is performed. The library might also contain functionality that intentionally exposes internal application data for debugging purposes.
If the library is used in a web application, the application developer is responsible for filtering inputs or escaping outputs as necessary and for verifying that the used functionality is safe for use within the intended context.
-Vulnerabilities specific to the use outside of a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes.
+Vulnerabilities specific to the use outside a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes.
final class Differ
{
- public const OLD = 0;
-
- public const ADDED = 1;
-
- public const REMOVED = 2;
-
- public const DIFF_LINE_END_WARNING = 3;
-
+ public const OLD = 0;
+ public const ADDED = 1;
+ public const REMOVED = 2;
+ public const DIFF_LINE_END_WARNING = 3;
public const NO_LINE_END_EOF_WARNING = 4;
private DiffOutputBuilderInterface $outputBuilder;
final class Line
{
- public const ADDED = 1;
-
- public const REMOVED = 2;
-
+ public const ADDED = 1;
+ public const REMOVED = 2;
public const UNCHANGED = 3;
private int $type;
private string $content;
if ($from[$i] === $to[$j]) {
$current[$j + 1] = $prev[$j] + 1;
} else {
- $current[$j + 1] = max($current[$j], $prev[$j + 1]);
+ // don't use max() to avoid function call overhead
+ if ($current[$j] > $prev[$j + 1]) {
+ $current[$j + 1] = $current[$j];
+ } else {
+ $current[$j + 1] = $prev[$j + 1];
+ }
}
}
}
for ($i = 1; $i <= $fromLength; $i++) {
for ($j = 1; $j <= $toLength; $j++) {
- $o = ($j * $width) + $i;
- $matrix[$o] = max(
- $matrix[$o - 1],
- $matrix[$o - $width],
- $from[$i - 1] === $to[$j - 1] ? $matrix[$o - $width - 1] + 1 : 0
- );
+ $o = ($j * $width) + $i;
+
+ // don't use max() to avoid function call overhead
+ $firstOrLast = $from[$i - 1] === $to[$j - 1] ? $matrix[$o - $width - 1] + 1 : 0;
+
+ if ($matrix[$o - 1] > $matrix[$o - $width]) {
+ if ($firstOrLast > $matrix[$o - 1]) {
+ $matrix[$o] = $firstOrLast;
+ } else {
+ $matrix[$o] = $matrix[$o - 1];
+ }
+ } else {
+ if ($firstOrLast > $matrix[$o - $width]) {
+ $matrix[$o] = $firstOrLast;
+ } else {
+ $matrix[$o] = $matrix[$o - $width];
+ }
+ }
}
}