You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ji...@apache.org on 2018/09/05 09:37:14 UTC

lucene-solr:branch_7x: LUCENE-8476: Optimizations in UserDictionary (KoreanAnalyzer)

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 7f0967ad9 -> 7595fd389


LUCENE-8476: Optimizations in UserDictionary (KoreanAnalyzer)

Signed-off-by: Namgyu Kim <kn...@gmail.com>
Signed-off-by: Jim Ferenczi <ji...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7595fd38
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7595fd38
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7595fd38

Branch: refs/heads/branch_7x
Commit: 7595fd3892b9543978abeeac014993d3a4508fd5
Parents: 7f0967a
Author: Namgyu Kim <kn...@gmail.com>
Authored: Wed Sep 5 00:12:10 2018 +0900
Committer: Jim Ferenczi <ji...@apache.org>
Committed: Wed Sep 5 11:37:05 2018 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                                             | 3 +++
 .../org/apache/lucene/analysis/ko/dict/UserDictionary.java     | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7595fd38/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 2a45082..0c45501 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -163,6 +163,9 @@ Other:
 
 * LUCENE-765: Improved org.apache.lucene.index javadocs. (Mike Sokolov)
 
+* LUCENE-8476: Remove redundant nullity check and switch to optimized List.sort in the
+  Korean's user dictionary. (Namgyu Kim)
+
 ======================= Lucene 7.4.1 =======================
 
 Bug Fixes:

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7595fd38/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
----------------------------------------------------------------------
diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
index c5378a9..539b9e7 100644
--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
@@ -20,7 +20,6 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
@@ -81,8 +80,7 @@ public final class UserDictionary implements Dictionary {
 
   private UserDictionary(List<String> entries) throws IOException {
     final CharacterDefinition charDef = CharacterDefinition.getInstance();
-    Collections.sort(entries,
-        Comparator.comparing(e -> e.split("\\s+")[0]));
+    entries.sort(Comparator.comparing(e -> e.split("\\s+")[0]));
 
     PositiveIntOutputs fstOutput = PositiveIntOutputs.getSingleton();
     Builder<Long> fstBuilder = new Builder<>(FST.INPUT_TYPE.BYTE2, fstOutput);
@@ -95,7 +93,7 @@ public final class UserDictionary implements Dictionary {
     for (String entry : entries) {
       String[] splits = entry.split("\\s+");
       String token = splits[0];
-      if (lastToken != null && token.equals(lastToken)) {
+      if (token.equals(lastToken)) {
         continue;
       }
       char lastChar = entry.charAt(entry.length()-1);