-
Notifications
You must be signed in to change notification settings - Fork 388
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-17540 update SupplementalDataInfo reader to not use reentrant XPathParts #3632
Conversation
…athParts - clarify distinction between XPathParts and SimpleXPathParts - push XPathParts.size() and other API up to XPathValue.size() - use SimpleXPathParts instead of XPathParts in SupplementalDataInfo
this was more work than made sense for v45 so split out. |
* | ||
* <p>Caches values for fast lookup. | ||
* | ||
* <p>For use at static init time, or anywhere a simpler API can be used, see {@link |
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.
A downside of SimpleXPathParts is that it doesn't cache, right? That should be mentioned here also, because it is a downside to using SimpleXPathParts for repeated usage.
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.
Yes. This should say, static init time where XPaths that are going to be read only once are used. Especially supplemental data, where all XPaths are unique and caching doesn't help.
|
||
/** | ||
* Get the attributes for the nth element (negative index is from end). Returns null or an empty | ||
* map if there's nothing. PROBLEM: exposes internal map |
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 better to return an ImmutableMap; that way we are guaranteed that nothing can change it.
Can discuss tradeoffs offline.
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.
That is, something like the following.
- from public Element makeImmutable() {
- extract the following into a method in a common location
if (attributes != null && !(attributes instanceof ImmutableMap)) {
attributes = ImmutableMap.copyOf(attributes);
}
- From public XPathParts freeze() {
- extract the following into a method in a common location, changing to call the above method instead of Element.makeImmutable()
// ensure that it can't be modified. Later we can fix all the call sites to check
// frozen.
List<Element> temp = new ArrayList<>(elements.size());
for (Element element : elements) {
temp.add(element.makeImmutable());
}
elements = ImmutableList.copyOf(temp);
- then change the following to call that method after the handleParse call
SimpleXPathParts(String xpath) {
handleParse(xpath, true);
}
There are alternatives, eg copy the code into SimpleXPathParts, or have an Elements base class, etc.
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.
PROBLEM: exposes internal map
comment and code is from the original XPathParts implementation. Perhaps that's a good follow up item as a separate concern from this one?
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.
Makes sense. Can you clone a ticket for that?
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.
@macchiati PTAL, updated the comments. The immutability is in another ticket |
note this is for v46 - see also #3631
CLDR-17540
ALLOW_MANY_COMMITS=true