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

fix: Correct arraycopy source and destination in dropRow method #130

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

mitsuki31
Copy link
Owner

Overview

This pull request addresses an issue in the Matrix class where the System.arraycopy method was used incorrectly in the dropRow method. Specifically, the source and destination parameters in System.arraycopy were swapped, which led to improper handling of row removal from the matrix.

Changes Made

  • Corrected the usage of System.arraycopy:
    • Source Parameter: Updated from newEntries[destRow++] to entries[i].
    • Destination Parameter: Updated from entries[i] to newEntries[destRow++].

These changes ensure that the correct row data is copied from the original matrix to the new matrix after a row has been dropped.

Reason for the Change

The initial implementation of System.arraycopy mistakenly swapped the source and destination arrays. As a result, the dropRow method did not correctly transfer data from the original matrix to the new matrix, potentially leading to incorrect matrix content.

Impact

This fix corrects the behavior of row removal in the Matrix class, ensuring that the matrix operations produce accurate results. Users of the Matrix class should experience improved reliability when performing row deletions.

- Fixed the source and destination parameters in `System.arraycopy` to correctly handle the dropping of a row from the matrix.
- The source was incorrectly set to `newEntries[destRow++]`, which is now updated to `entries[i]`, and the destination is updated to `newEntries[destRow++]`.
@mitsuki31 mitsuki31 added bugfix Fixes some bug or issue lang:java Some changes on Java code patch Patch update labels Sep 13, 2024
@mitsuki31 mitsuki31 added this to the v1.5.0 milestone Sep 13, 2024
@mitsuki31 mitsuki31 self-assigned this Sep 13, 2024
@mitsuki31 mitsuki31 merged commit 654cb32 into master Sep 13, 2024
34 checks passed
@mitsuki31 mitsuki31 deleted the fix/address-incorrect-call-arraycopy-in-drop-row branch September 13, 2024 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes some bug or issue lang:java Some changes on Java code patch Patch update
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant