Skip to content

Change lazy var in BasicFormat that are always evaluated to let #1962

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
Jul 29, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 28, 2023

Using lazy var only is beneficial if the variable is not always accessed and if we can thus skip the computation. But quite a few of these were always accessed in BasicFormat now. I didn’t measure but I remember that there’s a tiny performance penalty associated with lazy var, which doesn’t give us any benefits if the variable is always accessed. Thus, change them to let.

Using `lazy var` only is beneficial if the variable is not always accessed and if we can thus skip the computation. But quite a few of these were always accessed in BasicFormat now. I didn’t measure but I remember that there’s a tiny performance penalty associated with `lazy var`, which doesn’t give us any benefits if the variable is always accessed. Thus, change them to `let`.
@ahoppen ahoppen requested a review from bnbarham July 28, 2023 16:14
@ahoppen
Copy link
Member Author

ahoppen commented Jul 28, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jul 28, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit e04c5c1 into swiftlang:main Jul 29, 2023
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