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_r287612088
##########
File path: .idea/inspectionProfiles/Druid.xml
##########
@@ -306,6 +303,11 @@
<constraint name="x" maxCount="2147483647" within="" contains="" />
<constraint name="ImmutableMap" regexp="Immutable.*" within=""
contains="" />
</searchConfiguration>
+ <searchConfiguration name="Use Map.putIfAbsent() instead of
containsKey() + put()" created="1558868694225" text="if (!$m$.containsKey($k$))
{ $m$.put($k$, $v$); }" recursive="false" caseInsensitive="true"
type="JAVA">
Review comment:
This isn't always good advice: in particular, if `v` is expensive to compute
then computeIfAbsent should be used instead of putIfAbsent. This is because
putIfAbsent computes `v` eagerly, whereas containsKey + put (or
computeIfAbsent) computes `v` lazily. This can also have a deeper effect on
behavior, if computation of `v` has side effects.
----------------------------------------------------------------
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]