Skip to content

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
@ahoppen ahoppen deleted the ahoppen/let-instead-of-lazy-var branch August 4, 2025 10: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.

3 participants