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

Remove double-brace initialization and wrap constant collections in Collection.unmodifiable{Set,Map} #228

Merged
merged 3 commits into from Dec 22, 2019

Conversation

Clashsoft
Copy link
Contributor

@Clashsoft Clashsoft commented Dec 22, 2019

Double-brace initialization is commonly abused for its brevity, but has performance and clarity implications.

The use of Collections.unmodifiableSet and unmodifiableMap prevents outsider classes from modifying these collections, which is not desirable.

…ollection.unmodifiable{Set,Map}

[Double-brace initialization](https://stackoverflow.com/questions/1958636/what-is-double-brace-initialization-in-java) is commonly abused for its brevity, but has performance and clarity implications.

The use of `Collections.unmodifiableSet` and `unmodifiableMap` prevents outsider classes from modifying these collections, which is not desirable.
@parrt
Copy link
Member

parrt commented Dec 22, 2019

Wow. crazy performance issue. allowing. thanks!

@parrt parrt merged commit b59a8ea into antlr:master Dec 22, 2019
@Clashsoft Clashsoft deleted the no-double-brace-init branch December 22, 2019 17:13
@parrt parrt added this to the 4.3 milestone Jan 16, 2020
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.

None yet

2 participants