You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2020/09/01 23:03:13 UTC
[lucene-solr] branch branch_8x updated: SOLR-14579: reverting
incorrect comments
This is an automated email from the ASF dual-hosted git repository.
erick pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new a107248 SOLR-14579: reverting incorrect comments
a107248 is described below
commit a1072488921ddd407577be8347be431af6832797
Author: Erick Erickson <Er...@gmail.com>
AuthorDate: Tue Sep 1 18:59:08 2020 -0400
SOLR-14579: reverting incorrect comments
(cherry picked from commit 594d676a951a75038e1ebc5ed867a242b48c3149)
---
.../java/org/apache/solr/common/util/Utils.java | 35 ----------------------
1 file changed, 35 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
index 618f7e1..5199428 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
@@ -97,41 +97,6 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
public class Utils {
- // Why static lambdas? Even though they require SuppressWarnings? This is
- // purely an optimization. Comparing:
- //
- // mapObject.computeIfAbsent(key, o -> new HashMap<>());
- //
- // vs.
- //
- // mapObject.computeIfAbsent(key, Utils.NEW_HASHMAP_FUN)
- //
- //
- // The first code fragment is executed as following
- //
- // s.computeIfAbsent(key, new Function() {
- // @Override
- // public Object apply(String key) {
- // return new HashMap<>();
- // }
- // }
- //
- // So, there are two problems with this
- //
- // A new anonymous inner class is created for that lambda. This one extra
- // class becomes a part of your binary a new instance of that class is
- // created everytime the computeIfAbsent() method is invoked, irrespective
- // of whether the value is absent for that key or not. Now imagine that
- // method getting called millions of times and creating millions of such
- // objects for no reason
- //
- // OTOH
- //
- // Utils.NEW_HASHMAP_FUN
- // Only a single anonymous class is created for the entire codebase
- // Only single instance of that object is created in the VM
- //
- // See SOLR-14579.
@SuppressWarnings({"rawtypes"})
public static final Function NEW_HASHMAP_FUN = o -> new HashMap<>();