Skip to content

Don’t use arrays in consume functions #1314

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
Feb 8, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 6, 2023

Creating arrays for consume(ifAny:) and friends incurs memory allocations and reference counting costs. Stamp out copies of consume(if:) for up to three different kinds and start using RawTokenKindSubset if more kinds need to be checked.

This improves performance of parsing MovieSwiftUI by 5%.

rdar://103774645

@ahoppen ahoppen requested a review from rintaro February 6, 2023 11:23
@ahoppen
Copy link
Member Author

ahoppen commented Feb 6, 2023

@swift-ci Please test

@@ -98,7 +98,7 @@ final class AttributeTests: XCTestCase {
@1️⃣rethrows
protocol P { }
""",
substructure: Syntax(TokenSyntax.identifier("rethrows")),
substructure: Syntax(TokenSyntax.keyword(.rethrows)),
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, what changed the behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh that was because I forgot to check remapping in consume(if:). Fixed now.

Creating arrays for `consume(ifAny:)` and friends incurs memory allocations and reference counting costs. Stamp out copies of `consume(if:)` for up to three different kinds and start using `RawTokenKindSubset` if more kinds need to be checked.

This improves performance of parsing MovieSwiftUI by 5%.

rdar://103774645
@ahoppen
Copy link
Member Author

ahoppen commented Feb 7, 2023

@swift-ci Please test

1 similar comment
@ahoppen
Copy link
Member Author

ahoppen commented Feb 8, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit f6ba4aa into swiftlang:main Feb 8, 2023
@ahoppen ahoppen deleted the ahoppen/no-arrays branch February 8, 2023 19:49
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