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

diff: simplify LCS_matrix() #915

Merged
merged 1 commit into from
Jan 8, 2025
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Jan 8, 2025

  • Initialise $x[$i] to new listref [0] in one statement, instead of assigning list element 0 separately
  • Calling standard max() function avoids temporary variables when compared items are different
  • Write loops in idiomatic form with ranges
  • This was intended as a readability change, but I observed that when generating diffs on a large text file the performance is slightly improved
%wc -l bc bc.new 
  2761 bc
  2768 bc.new
  5529 total
%time perl diff.old -u bc bc.new > /dev/null
real	0m11.003s
...
real	0m10.845s
...
real	0m10.965s

%time perl diff.new -u bc bc.new > /dev/null
real	0m9.470s
...
real	0m9.546s
...
real	0m9.329s

* Initialise $x[$i] to new listref [0] in one statement, instead of assigning list element 0 separately
* Calling standard max() function avoids temporary variables when compared items are different
* Write loops in idiomatic form with ranges
* This was intended as a readability change, but I observed that when generating diffs on a large text files the performance is slightly improved

%time perl diff.old -u bc bc.new > /dev/null
real	0m11.003s
...
real	0m10.845s
...
real	0m10.965s

%time perl diff.new -u bc bc.new > /dev/null
real	0m9.470s
...
real	0m9.546s
...
real	0m9.329s
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: diff The diff program labels Jan 8, 2025
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 8, 2025 02:43 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Jan 8, 2025

Pull Request Test Coverage Report for Build 12663082475

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 72.407%

Totals Coverage Status
Change from base Build 12647728061: 0.0%
Covered Lines: 349
Relevant Lines: 482

💛 - Coveralls

Copy link
Owner

@briandfoy briandfoy left a comment

Choose a reason for hiding this comment

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

Nice.

@briandfoy briandfoy merged commit 46f717e into briandfoy:master Jan 8, 2025
22 of 23 checks passed
@briandfoy briandfoy self-assigned this Jan 8, 2025
@briandfoy briandfoy removed the Priority: low get to this whenever label Jan 8, 2025
@briandfoy briandfoy added the Status: accepted The fix is accepted label Jan 8, 2025
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: diff The diff program Status: released there is a new release with this fix Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants