-
Notifications
You must be signed in to change notification settings - Fork 389
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
CLDR-17014 Use singleton to avoid synchronized in ExtraPaths #4330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, thanks!
paths = new HashSet<>(); | ||
addPaths(NameType.SCRIPT); | ||
addPaths(NameType.LANGUAGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the end of this method, you need to make paths be an ImmutableSet. Add an extra parameter to addPaths, etc. and change this to:
paths = new HashSet<>(); | |
addPaths(NameType.SCRIPT); | |
addPaths(NameType.LANGUAGE); | |
Set<String> temp = new TreeSet(); // might as well put them in order; easier to debug | |
addPaths(NameType.SCRIPT, temp); | |
addPaths(NameType.LANGUAGE, temp); | |
paths = ImmutableSet.copyOf(temp); // preserves order (Sets.copyOf doesn't) |
@macchiati the 2nd commit makes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be slightly better to add pathsTemp as a parameter to addPaths, but this works and only costs a trifling bit of memory.
Making it a parameter might reduce the data size by a few bytes, but increase the code size by a slightly larger number of bytes, since addPaths and addAltPath have dozens of callers. Anyway, this can be revisited in follow-up refactoring when moving more code from CLDRFile to ExtraPaths. |
good point! |
CLDR-17014
ALLOW_MANY_COMMITS=true