Skip to content

Don't guard assertions behind #if DEBUG #1526

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
Apr 14, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 13, 2023

Some assertions were still guarded by a #if DEBUG. Since we are now also enabling assertions in release builds if SWIFTSYNTAX_ENABLE_ASSERTIONS is set, this is no longer correct. Convert most of them to plain preconditions. I have measured and could not detect a performance difference when parsing MovieSwiftU.

Some assertions were still guarded by a `#if DEBUG`. Since we are now also enabling assertions in release builds if `SWIFTSYNTAX_ENABLE_ASSERTIONS` is set, this is no longer correct. Convert most of them to plain preconditions. I have measured and could not detect a performance difference when parsing MovieSwiftU.
@ahoppen ahoppen requested a review from bnbarham April 13, 2023 02:10
@ahoppen
Copy link
Member Author

ahoppen commented Apr 13, 2023

@swift-ci Please test

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

I have measured and could not detect a performance difference when parsing MovieSwiftU.

I wouldn't expect much parsing difference with these changes. It'd be good to do a quick test on something that does more re-writing.

@ahoppen
Copy link
Member Author

ahoppen commented Apr 14, 2023

I just tested and couldn’t find a significant performance regression when linting MovieSwiftUI using swift-format.

@ahoppen ahoppen merged commit 17e41b6 into swiftlang:main Apr 14, 2023
@ahoppen ahoppen deleted the ahoppen/no-debug-guards branch April 14, 2023 21:38
ahoppen added a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 2023
ahoppen added a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 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