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
Replace usage of Maps.newHashMapWithExpectedSize() with standard Java #2976
base: main
Are you sure you want to change the base?
Replace usage of Maps.newHashMapWithExpectedSize() with standard Java #2976
Conversation
org.eclipse.xtext.ui/src/org/eclipse/xtext/ui/preferences/OptionsConfigurationBlock.java
Outdated
Show resolved
Hide resolved
...se.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGeneratorTemplates.xtend
Outdated
Show resolved
Hide resolved
I think @szarnekow should review this, but personally, I'm not a big fan of such strange expressions for computing the size ;) another note: |
Is it about the expression or specifying the size at all? If it is the latter, I can also remove it. If it is the former I'm fine to restrict this PR to the change of
That's right. But I have only used it in two places where the map is passed as |
org.eclipse.xtext/src/org/eclipse/xtext/resource/impl/EObjectDescriptionLookUp.java
Outdated
Show resolved
Hide resolved
4394639
to
85ca11f
Compare
I have now reverted the changes that require computation of the capacity. That can be replaced once the Java-19 |
In Java-19 there is even static factory method
HashMap.newHashMap(int)
that can be used as a drop-in replacement once Java-19 or later is required.For now I calculate the necessary capacity explicitly using the formula:
expected-size *4/3+1
.The change in XtextGeneratorTemplates also removes the usage of
Maps.newHashMapWithExpectedSize()
of many generated Activators, but I haven't changed them manually. I assume they should be regenerated, shouldn't they?Part of #2975