Skip to content

Eliminates redundant array creation in convinience NSString.init() #2810

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 2 commits into from
Jun 5, 2020

Conversation

valeriyvan
Copy link
Contributor

No description provided.

let characters = Array<unichar>(repeating: 0, count: 1)
self.init(characters: characters, length: 0)
var nul: unichar = 0
self.init(characters: &nul, length: 0)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is ultimately an empy string, can the whole function body be reduced to

self.init("")

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it could.

@spevans
Copy link
Contributor

spevans commented Jun 4, 2020

@swift-ci please test

@valeriyvan valeriyvan changed the title Eliminates redundent array creation in convinience NSString.init() Eliminates redundant array creation in convinience NSString.init() Jun 5, 2020
@spevans
Copy link
Contributor

spevans commented Jun 5, 2020

@swift-ci please test and merge

@swift-ci swift-ci merged commit f89f2e6 into swiftlang:master Jun 5, 2020
@valeriyvan valeriyvan deleted the NSString branch August 21, 2020 17:56
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