You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2026/02/09 14:42:44 UTC
(lucene) branch main updated: Use more efficient ArrayDeque instead of LinkedList (#15682)
This is an automated email from the ASF dual-hosted git repository.
uschindler 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 44d6638329e Use more efficient ArrayDeque instead of LinkedList (#15682)
44d6638329e is described below
commit 44d6638329ecb7f2ea095052fd800b59cbd62d67
Author: Renato Haeberli <re...@onnet.ch>
AuthorDate: Mon Feb 9 15:42:39 2026 +0100
Use more efficient ArrayDeque instead of LinkedList (#15682)
Co-authored-by: Renato Haeberli <re...@haeberli-consulting.com>
---
lucene/CHANGES.txt | 2 ++
.../lucene/analysis/compound/CompoundWordTokenFilterBase.java | 9 +++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 755e3447a28..adf810552d2 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -73,6 +73,8 @@ New Features
Improvements
---------------------
+* GITHUB#15682: Use ArrayDeque instead of LinkedList in CompoundWordTokenFilterBase.java. (Renato Haeberli)
+
* GITHUB#15568: Add markdown support for javadocs and modernize highlighting a bit. (Dawid Weiss)
* GITHUB#14972: Require named thread factory in ThreadPoolExecutor constructors. (Dawid Weiss)
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
index bc5f4b825f5..7a389ca512a 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
@@ -17,7 +17,8 @@
package org.apache.lucene.analysis.compound;
import java.io.IOException;
-import java.util.LinkedList;
+import java.util.ArrayDeque;
+import java.util.Queue;
import org.apache.lucene.analysis.CharArraySet;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
@@ -37,7 +38,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter {
public static final int DEFAULT_MAX_SUBWORD_SIZE = 15;
protected final CharArraySet dictionary;
- protected final LinkedList<CompoundToken> tokens;
+ protected final Queue<CompoundToken> tokens;
protected final int minWordSize;
protected final int minSubwordSize;
protected final int maxSubwordSize;
@@ -79,7 +80,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter {
int maxSubwordSize,
boolean onlyLongestMatch) {
super(input);
- this.tokens = new LinkedList<>();
+ this.tokens = new ArrayDeque<>();
if (minWordSize < 0) {
throw new IllegalArgumentException("minWordSize cannot be negative");
}
@@ -100,7 +101,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter {
public final boolean incrementToken() throws IOException {
if (!tokens.isEmpty()) {
assert current != null;
- CompoundToken token = tokens.removeFirst();
+ CompoundToken token = tokens.remove();
restoreState(current); // keep all other attributes untouched
termAtt.setEmpty().append(token.txt);
offsetAtt.setOffset(token.startOffset, token.endOffset);