8289658: Avoid redundant LinkedHashMap.get call in TagletManager.addNewSimpleCustomTag

Reviewed-by: attila, prappo
This commit is contained in:
Andrey Turbanov 2022-08-23 07:44:01 +00:00
parent 84936e9278
commit b4e1aa87e3

View File

@ -311,16 +311,15 @@ public class TagletManager {
if (tagName == null || locations == null) { if (tagName == null || locations == null) {
return; return;
} }
Taglet tag = allTaglets.get(tagName); // remove + put in both branches below move the tag to the back of the map's ordering
Taglet tag = allTaglets.remove(tagName);
if (tag == null || header != null) { if (tag == null || header != null) {
allTaglets.remove(tagName);
allTaglets.put(tagName, new SimpleTaglet(tagName, header, locations)); allTaglets.put(tagName, new SimpleTaglet(tagName, header, locations));
if (Utils.toLowerCase(locations).indexOf('x') == -1) { if (Utils.toLowerCase(locations).indexOf('x') == -1) {
checkTagName(tagName); checkTagName(tagName);
} }
} else { } else {
//Move to back // Move existing tag to the back
allTaglets.remove(tagName);
allTaglets.put(tagName, tag); allTaglets.put(tagName, tag);
} }
} }