Skip to content

[docs] clarify todo about deinitializing a single element #40132

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
Nov 11, 2021

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Nov 10, 2021

Clarify TODO item about deinitializing a single element in UnsafeMutablePointer.deinitialize(count:).

@glessard
Copy link
Contributor Author

glessard commented Nov 10, 2021

@atrick This tweak has been hinted at as a FIXME in this function for years. Obviously it's fine when deinitializing a number of elements that's a constant in source code. Would this be a bad thing when the argument is some statically unknown variable?

@eeckstein
Copy link
Contributor

Yes, the TODO meant something different: if it's statically a constant of 1, replace it with a simple destroy. In not done already, that can be easily done in IRGen.
Such a check at runtime adds code size. We should only do this if there is evidence (e.g. from benchmarks) that this really gives significant performance wins.

@glessard glessard force-pushed the ump-deinitialize-todo branch from f34a9a4 to bda3dd5 Compare November 11, 2021 16:38
@glessard
Copy link
Contributor Author

@eeckstein I made it a clearer TODO instead of a FIXME.

@glessard glessard force-pushed the ump-deinitialize-todo branch from bda3dd5 to 5ef8c54 Compare November 11, 2021 16:41
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

thanks

@glessard glessard changed the title [stdlib] special-case deinitializing one element [docs] clarify todo about deinitializing a single element Nov 11, 2021
@glessard
Copy link
Contributor Author

@swift-ci please smoke test and merge

@swiftlang swiftlang deleted a comment from swift-ci Nov 11, 2021
@glessard glessard marked this pull request as ready for review November 11, 2021 21:28
@glessard glessard merged commit 183042e into swiftlang:main Nov 11, 2021
@glessard glessard deleted the ump-deinitialize-todo branch November 11, 2021 21:32
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.

2 participants