gianm commented on a change in pull request #7764: #7316 Use Map.putIfAbsent()
instead of containsKey() + put()
URL: https://github.com/apache/incubator-druid/pull/7764#discussion_r287612383
##########
File path:
server/src/main/java/org/apache/druid/server/http/DataSourcesResource.java
##########
@@ -549,9 +549,7 @@ private ImmutableDruidDataSource getDataSource(final
String dataSourceName)
continue;
}
- if (!tierDistinctSegments.containsKey(tier)) {
- tierDistinctSegments.put(tier, new HashSet<>());
- }
+ tierDistinctSegments.putIfAbsent(tier, new HashSet<>());
Review comment:
This is a good candidate for `computeIfAbsent`, to avoid the extra
allocation. (It's short lived so not really a big deal, but, still.)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]