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

[Swift] Remove Recognizer.tokenTypeMapCache and .ruleIndexMapCache. #2122

Merged
merged 1 commit into from
Nov 29, 2017

Conversation

ewanmellor
Copy link
Contributor

Remove Recognizer.tokenTypeMapCache and .ruleIndexMapCache. These
were easily replaced in Swift with lazy vars. The input to these
two caches are fixed fields on the Recognizer (the Vocabulary and
rule names respectively) so a lazy var suffices.

Note that these differed compared with the Java runtime -- they are
declared as static in Java and therefore the caches are shared across
all recognizer instances, but the Swift runtime had them as Recognizer
instance variables, which meant that at most we had a cache with one
entry which got destroyed along with the parser. Regardless, using
lazy vars is still simpler.

This removes the only usage of ArrayWrapper in the Swift runtime, so
delete that too.

Remove Recognizer.tokenTypeMapCache and .ruleIndexMapCache.  These
were easily replaced in Swift with lazy vars.  The input to these
two caches are fixed fields on the Recognizer (the Vocabulary and
rule names respectively) so a lazy var suffices.

Note that these differed compared with the Java runtime -- they are
declared as static in Java and therefore the caches are shared across
all recognizer instances, but the Swift runtime had them as Recognizer
instance variables, which meant that at most we had a cache with one
entry which got destroyed along with the parser.  Regardless, using
lazy vars is still simpler.

This removes the only usage of ArrayWrapper in the Swift runtime, so
delete that too.
@parrt parrt added this to the 4.7.1 milestone Nov 29, 2017
@parrt parrt merged commit bd4f1a9 into antlr:master Nov 29, 2017
@ewanmellor ewanmellor deleted the swift-remove-recognizer-caches branch November 30, 2017 08:02
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