dsmiley commented on code in PR #4893:
URL: https://github.com/apache/solr/pull/4893#discussion_r3985737020


##########
solr/solrj/src/java/org/apache/solr/common/util/DeprecationLog.java:
##########
@@ -41,11 +42,25 @@ public class DeprecationLog {
    * @return true if logged
    */
   public static boolean log(String featureId, String message) {
-    if (alreadyLogged.putIfAbsent(featureId, message) != null) {
+    return log(featureId, () -> message);
+  }
+
+  /**
+   * Like {@link #log(String, String)}, but only builds the message if this is 
the first time {@code
+   * featureId} is logged. Use this when building the message isn't free and 
the call site runs
+   * often (e.g. on every property lookup).
+   *
+   * @return true if logged
+   */
+  public static boolean log(String featureId, Supplier<String> message) {
+    if (alreadyLogged.containsKey(featureId)) {
+      return false;
+    }

Review Comment:
   This first part is needless; surely putIfAbsent will handle this, right?
   Is this an optimization?  If it is, a comment should clearly say so.  But 
I'm suspicious it's any faster than putIfAbsent; surely that one can bail fast. 
 I looked at the code for it in ConcurrentHashMap and I think it's good.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to