You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/03/17 06:24:46 UTC

(lucene) branch main updated: Replace empty array with lambda expression to call Collection#toArray. (#15833)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new 4a3cdbcd5f9 Replace empty array with lambda expression to call Collection#toArray. (#15833)
4a3cdbcd5f9 is described below

commit 4a3cdbcd5f9fd9c894d98915bc6a0d375cd3231e
Author: zhouhui <vs...@163.com>
AuthorDate: Tue Mar 17 14:24:39 2026 +0800

    Replace empty array with lambda expression to call Collection#toArray. (#15833)
    
    * Replace empty array with lambda expression to call Collection#toArray.
    
    * Add changes entry.
---
 lucene/CHANGES.txt                                                 | 2 +-
 lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java | 2 +-
 lucene/core/src/java/org/apache/lucene/search/Explanation.java     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index de75aac63c3..b599dafaf4a 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -113,7 +113,7 @@ Improvements
 
 Optimizations
 ---------------------
-* GITHUB#15681: Replace pre-sized array or empty array with lambda expression to call Collection#toArray. (Zhou Hui)
+* GITHUB#15681, GITHUB#15833: Replace pre-sized array or empty array with lambda expression to call Collection#toArray. (Zhou Hui)
 
 * GITHUB#13782: Replace handwritten loops compare with Arrays.compareUnsigned in TermsEnum and TermsEnumFrame classes. (Zhou Hui)
 
diff --git a/lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java b/lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java
index 3ac25dd93c4..6eb4b8aa1b3 100644
--- a/lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java
+++ b/lucene/core/src/java/org/apache/lucene/search/ConjunctionDISI.java
@@ -159,7 +159,7 @@ final class ConjunctionDISI extends FilterDocIdSetIterator {
 
     lead1 = iterators.get(0);
     lead2 = iterators.get(1);
-    others = iterators.subList(2, iterators.size()).toArray(new DocIdSetIterator[0]);
+    others = iterators.subList(2, iterators.size()).toArray(DocIdSetIterator[]::new);
   }
 
   private int doNext(int doc) throws IOException {
diff --git a/lucene/core/src/java/org/apache/lucene/search/Explanation.java b/lucene/core/src/java/org/apache/lucene/search/Explanation.java
index 460a20e65cb..7e9e474ecf2 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Explanation.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Explanation.java
@@ -97,7 +97,7 @@ public final class Explanation {
 
   /** The sub-nodes of this explanation node. */
   public Explanation[] getDetails() {
-    return details.toArray(new Explanation[0]);
+    return details.toArray(Explanation[]::new);
   }
 
   /** Render an explanation as text. */