Skip to content
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

[C++] Use faster alternative to dynamic_cast when not testing inherit… #3318

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

jcking
Copy link
Collaborator

@jcking jcking commented Oct 25, 2021

By default the generated lexer/parsers use dynamic_cast everywhere. This is not necessary when casting from a base class to a derived class and not inspecting the result of dynamic_cast. In those cases we can use static_cast. This patch introduces antlrcpp:downCast which uses dynamic_cast in debug builds and static_cast in release builds. This should result in faster generated code in release-like builds.

@jcking jcking force-pushed the cpp-static-cast branch 3 times, most recently from 9c17eb3 to 9697679 Compare October 25, 2021 20:06
@jcking jcking marked this pull request as ready for review October 25, 2021 20:33
@jcking
Copy link
Collaborator Author

jcking commented Oct 25, 2021

@mike-lischke Another one, likely of many.

@mike-lischke
Copy link
Member

mike-lischke commented Oct 26, 2021

@parrt This is a C++ only patch. It can be merged for the upcoming release or after that. Either is fine for me.

@parrt parrt added this to the 4.9.3 milestone Oct 26, 2021
@parrt parrt merged commit 7c7c917 into antlr:master Oct 26, 2021
@parrt
Copy link
Member

parrt commented Oct 26, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants