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

Improve PredictionContext performance, fix bugs #4196

Merged
merged 5 commits into from
Mar 28, 2023

Conversation

jimidle
Copy link
Collaborator

@jimidle jimidle commented Mar 20, 2023

The PredictionContext in Go was an interface prior to this change. However, there was no need for an interface as the differences in the types were minor and can be catered for much faster with a simple struct and a few case statements. Interfaces are also not ideal for Generics. We can end up needing 3 pointer dereferences just to look at an int.

This PR also changes Intervals to stop using pointers. They are two simple to need that.

Interfaces require two pointer lookups for functions and when used as
Generic, they require three. This change therefore yields a small
performance upgrade.

This change also corrects one or two copmarisons that were using pointer
comparison instead of Equals() and were bugs in the code I inherited.

Signed-off-by: Jim.Idle <[email protected]>
@jimidle
Copy link
Collaborator Author

jimidle commented Mar 28, 2023

@parrt - I would appreciate it if you could merge this - I am now waiting for it to complete a big bug fix for config caching. Cheers.

@parrt parrt added this to the 4.12.1 milestone Mar 28, 2023
@parrt parrt merged commit 7141cf4 into antlr:dev Mar 28, 2023
@jimidle jimidle deleted the feature/lesspointy branch March 28, 2023 03:10
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.

2 participants