Skip to content

Fix the new Swift NSMutableArray subclass to match edge case behavior in two more cases #27504

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

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

Catfish-Man
Copy link
Contributor

We now support swapping an index with itself, and replacing subranges with elements already in the array

@Catfish-Man Catfish-Man self-assigned this Oct 2, 2019
@Catfish-Man Catfish-Man requested a review from lorentey October 2, 2019 22:10
@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@milseman
Copy link
Member

milseman commented Oct 2, 2019

These definitely need test cases, especially the situation where replaceSubrange would free the objects it is inserting

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

contents = Array(buf)
} else {
// We make an Array here to make sure that something is holding onto the
// objects in `buf`, since replaceSubrange could release them
Copy link
Contributor

Choose a reason for hiding this comment

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

Oof. Optimize later to check, I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it looks relevant in practice, sure

Copy link
Contributor

Choose a reason for hiding this comment

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

You're performing an extra copy this way, at least formally.

Copy link
Contributor

Choose a reason for hiding this comment

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

(which is the point, of course)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, but that just brings us down to NSMutableArray's speed, in theory. Anything better here would be a win on top of that which (probably) makes it nice to have rather than necessary.

@Catfish-Man Catfish-Man merged commit 5574372 into swiftlang:master Oct 3, 2019
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