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

Use copyMutableByteArrayNonOverlapping# when available #406

Merged

Conversation

clyring
Copy link
Member

@clyring clyring commented Jan 4, 2024

(The function documentation already demands "The two slices may not overlap.")

@andrewthad andrewthad merged commit 5f99571 into haskell:master Jan 4, 2024
12 checks passed
@konsumlamm
Copy link
Contributor

copyMutablePrimArray, which is currently also implemented using copyMutableByteArray#, documents that the regions may overlap if the source and destination are the same array (which is the only case in which the regions can overlap). IMO copyMutableByteArray and copyMutablePrimArray should have the same behaviour, so either we change this for PrimArrays too (which would be a breaking change), or we revert this. Given that copyMutableArray also allows overlapping arrays, I tend towards the former.

@andrewthad
Copy link
Collaborator

You're right. I had not remember that the API of PrimArray differs slightly. There is no movePrimArray at all, and copyPrimArray is documented to handle all the cases. We should probably

  1. Explicitly state that copyMutableByteArray supports overlapping arrays in the documentation.
  2. Soft deprecate moveByteArray. Not a real deprecate pragma. Just a mention in the documentation that copyMutableByteArray is preferred.
  3. Introduce copyMutableByteArrayNonOverlapping and copyMutablePrimArrayNonOverlapping, which will use the new primop on newer GHCs.

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.

3 participants