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

perf: New implemention for Diff() #191

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

leilei3167
Copy link
Contributor

Using set instead of nested for loops, the time complexity is reduced from O(n^2) to O(n)

Using set instead of nested for loops, the time complexity is reduced from O(n^2) to O(n)
@leilei3167
Copy link
Contributor Author

@elliotchance please take a look

@leilei3167
Copy link
Contributor Author

Results of the unit test:

$ go test -run ^TestDiff$ -v
=== RUN   TestDiff
=== RUN   TestDiff/BothEmpty
=== RUN   TestDiff/OnlyRemovedUnique
=== RUN   TestDiff/OnlyRemovedDuplicates
=== RUN   TestDiff/OnlyAddedUnique
=== RUN   TestDiff/OnlyAddedDuplicates
=== RUN   TestDiff/AddedAndRemovedUnique
=== RUN   TestDiff/AddedAndRemovedDuplicates
--- PASS: TestDiff (0.00s)
    --- PASS: TestDiff/BothEmpty (0.00s)
    --- PASS: TestDiff/OnlyRemovedUnique (0.00s)
    --- PASS: TestDiff/OnlyRemovedDuplicates (0.00s)
    --- PASS: TestDiff/OnlyAddedUnique (0.00s)
    --- PASS: TestDiff/OnlyAddedDuplicates (0.00s)
    --- PASS: TestDiff/AddedAndRemovedUnique (0.00s)
    --- PASS: TestDiff/AddedAndRemovedDuplicates (0.00s)
PASS
ok      github.com/elliotchance/pie/v2  0.196s

@elliotchance elliotchance merged commit a9ee294 into elliotchance:master Mar 24, 2023
@leilei3167 leilei3167 deleted the optimize-Diff branch March 25, 2023 05:27
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.

2 participants