Skip to content

[xcodegen] Avoid an intermediate String #78291

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

Conversation

hamishknight
Copy link
Contributor

We don't need to create an intermediate String when escaping characters in the plist.

We don't need to create an intermediate String
when escaping characters in the plist.
@hamishknight
Copy link
Contributor Author

@swift-ci please smoke test

mutating func appendEscaped(_ string: String) {
for char in string.utf8 {
if char == UInt8(ascii: "\\") || char == UInt8(ascii: "\"") {
append(UInt8(ascii: "\\"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
append(UInt8(ascii: "\\"))
append(UInt8(ascii: #"\"#))

🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When there's only a single character to escape I tend to prefer just writing the backslash, especially as things like #"""# look weird. I think I'd rather keep things locally consistent here, I don't feel too strongly about it though

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. I do not actually have a preference, but I was curious about yours, on the off chance that a raw string had occurred to you.

@AnthonyLatsis AnthonyLatsis added contributor experience swift-xcodegen Area → utils: swift-xcodegen labels Dec 19, 2024
@hamishknight hamishknight merged commit a3d9776 into swiftlang:main Dec 19, 2024
3 checks passed
@hamishknight hamishknight deleted the minor-xcodegen-optimization branch December 19, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor experience swift-xcodegen Area → utils: swift-xcodegen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants