Skip to content

Correct behavior for NSMutableData's replaceBytes(in:withBytes:length:) method #735

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

Closed
wants to merge 3 commits into from

Conversation

Jumhyn
Copy link
Member

@Jumhyn Jumhyn commented Dec 8, 2016

Explanation

Previously, replaceBytes(in:withBytes:length: 0) was a no-op when called as data.replaceBytes(in: range, withBytes: nil length: 0). This PR corrects this, and calls the underlying CFDataReplaceBytes in all cases. When replacementBytes is nil and length is 0, this deletes the bytes in range.

Scope

The scope of this change is limited to the single method noted above, and should be fully source compatible--only the internal implementation is changing.

SR Issue

SR-3404

Risk

There should be no risk to taking this change. Any code which relied on this call being a no-op did so in direct contradiction with the documentation.

Testing

A new test is also added to ensure that this method works as specified.

(Documentation taken from the NSMutableData API Reference)

@Jumhyn
Copy link
Member Author

Jumhyn commented Dec 12, 2016

@parkera Is this a reasonable change to include in Swift 3.1?

@parkera
Copy link
Contributor

parkera commented Dec 13, 2016

I think so; I just need to review this. If we merge to master in the next few weeks it'll be in Swift 3.1.

@parkera parkera self-assigned this Dec 13, 2016
@johnno1962
Copy link
Contributor

This was picked up in the end by #905. I think you can close this.

@alblue
Copy link
Contributor

alblue commented Oct 7, 2017

Yup, I concur.

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.

4 participants