Skip to content

Turn some static variables into static stored constants #2729

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
Jul 19, 2024

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 15, 2024

Computing OperatorTable.standardOperators is not trivial, make it static let instead of computed static variable.
So as SyntaxProtocol.structure implementations.

rintaro added 2 commits July 15, 2024 11:07
Returnning array literal from computed property allocates and
initializes the array buffer every time it's called, and they are
deallocated after use.
Make them stored properties so they stay in memory.
Building standard operator table is not trivial. Make is an immutable
stored property so it stays in memory once it's initialized.
@rintaro
Copy link
Member Author

rintaro commented Jul 16, 2024

@swift-ci Please test

return nil
}
guard case .layout(let childrenKeyPaths) = parent.kind.syntaxNodeType.structure else {
guard case .layout(let childrenKeyPaths) = self._syntaxNode.parent?.kind.syntaxNodeType.structure else {
Copy link
Member

Choose a reason for hiding this comment

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

Is self._syntaxNode.parent faster than parent?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my measurement, but I'm not 100% sure tbh. I will double check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this commit from the PR for now

@rintaro rintaro force-pushed the static-stored-constant branch from 0477185 to fad2743 Compare July 18, 2024 21:19
@rintaro
Copy link
Member Author

rintaro commented Jul 18, 2024

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jul 18, 2024

@swift-ci Please test Windows

@rintaro rintaro enabled auto-merge July 18, 2024 21:20
@rintaro
Copy link
Member Author

rintaro commented Jul 18, 2024

@swift-ci Please test Windows

@rintaro rintaro merged commit 8b53f92 into swiftlang:main Jul 19, 2024
3 checks passed
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