Skip to content
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

Introduce Myers algorithm in linear space #112

Merged
merged 14 commits into from
Jun 11, 2024

Conversation

lppedd
Copy link
Contributor

@lppedd lppedd commented May 16, 2024

This PR requires #111 to be merged first.
I will then rebase.

Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 94.21769% with 17 lines in your changes missing coverage. Please review.

Project coverage is 86.07%. Comparing base (875f4ce) to head (37933be).

Files Patch % Lines
...github/petertrr/diffutils/text/DiffRowGenerator.kt 93.61% 3 Missing and 6 partials ⚠️
...futils/algorithm/myers/MyersDiffWithLinearSpace.kt 92.78% 1 Missing and 6 partials ⚠️
...hub/petertrr/diffutils/algorithm/myers/PathNode.kt 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #112      +/-   ##
============================================
+ Coverage     84.26%   86.07%   +1.80%     
- Complexity      151      221      +70     
============================================
  Files            22       30       +8     
  Lines           534      632      +98     
  Branches         89      117      +28     
============================================
+ Hits            450      544      +94     
- Misses           57       59       +2     
- Partials         27       29       +2     
Flag Coverage Δ
unittests 86.07% <94.21%> (+1.80%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lppedd lppedd marked this pull request as ready for review May 17, 2024 09:40
@lppedd lppedd force-pushed the refactor/myers-linear-space branch from 45d28ee to f3d1caf Compare May 20, 2024 10:24
val origList = inlineDiffSplitter.split(joinedOrig)
val revList = inlineDiffSplitter.split(joinedRev)

// Copying of `origList` and `revList` is needed because otherwise `wrapInTag` results in ConcurrentModificationException
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petertrr I don't understand why this would throw a ConcurrentModificationException

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure TBH; this part was copied from the original library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petertrr no problem, I can remove it, it's not needed as we aren't operating on the lists concurrently.

@lppedd
Copy link
Contributor Author

lppedd commented May 20, 2024

I'm done with this one. The refactor: clean up DiffRowGenerator commit has a bit of changes but they're mostly to remove "untyped" lambdas.

This PR is a breaking API change for DiffRowGenerator.

.DS_Store
.kotlin/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kotlin 2.0 introduces a new folder to store metadata.


- fuzzy patches
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will port in another PR.

Copy link
Owner

@petertrr petertrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for disappearing. Your PR generally LGTM, I have just a couple of questions. Also, what's the breaking change in the DiffRowGenerator? Is it a new constructor parameter, or did I overlook something else?

@@ -19,11 +19,12 @@
package io.github.petertrr.diffutils.algorithm

import io.github.petertrr.diffutils.patch.DeltaType
import kotlin.jvm.JvmField

public data class Change(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if making the class @JvmRecord instead would have similar effect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petertrr we are targeting Java 8, so it wouldn't make any difference unfortunately.
But anyway, with records the only difference is method naming, e.g. getX() > x(), so you'd still not expose fields directly.


while (i < end1 || j < end2) {
if (i < end1 && j < end2 && equalizer.test(data.source[i], data.target[j])) {
// script.append(new KeepCommand<>(left.charAt(i)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the plan for the commented code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petertrr I'll get rid of them!

val origList = inlineDiffSplitter.split(joinedOrig)
val revList = inlineDiffSplitter.split(joinedRev)

// Copying of `origList` and `revList` is needed because otherwise `wrapInTag` results in ConcurrentModificationException
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure TBH; this part was copied from the original library.

@lppedd
Copy link
Contributor Author

lppedd commented Jun 4, 2024

what's the breaking change in the DiffRowGenerator

It's just the constructor, we introduced new interfaces so I'm not sure it would work straight away.
Edit: well, the new interfaces are not only there, so I'd say this is a general breaking change, but, guess it's ok!

@lppedd lppedd requested a review from petertrr June 5, 2024 08:11
Copy link
Owner

@petertrr petertrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for a nice improvement!

@petertrr petertrr merged commit edfab24 into petertrr:main Jun 11, 2024
3 checks passed
@lppedd
Copy link
Contributor Author

lppedd commented Jun 11, 2024

@petertrr np. I have another PR with a small cleanup and then it would be cool to do a release imo!

@lppedd
Copy link
Contributor Author

lppedd commented Jun 11, 2024

Ah I see you already released ahaha, well no problem, will be for another minor release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants