mirror of https://github.com/apache/lucene.git
Use orElseGet() to avoid unnecessary object allocation (#13048)
This commit is contained in:
parent
d69df16bf8
commit
d988f91aba
|
@ -259,6 +259,9 @@ Other
|
||||||
|
|
||||||
* GITHUB#12934: Cleaning up old references to Lucene/Solr. (Jakub Slowinski)
|
* GITHUB#12934: Cleaning up old references to Lucene/Solr. (Jakub Slowinski)
|
||||||
|
|
||||||
|
* GITHUB#12967, GITHUB#13038, GITHUB#13040, GITHUB#13042, GITHUB#13047, GITHUB#13048, GITHUB#13049, GITHUB#13050, GITHUB#13051:
|
||||||
|
Code cleanups and optimizations. (Dmitry Cherniachenko)
|
||||||
|
|
||||||
======================== Lucene 9.9.2 =======================
|
======================== Lucene 9.9.2 =======================
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
|
@ -519,7 +519,7 @@ public final class SearchPanelProvider implements SearchTabOperator {
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
.get(SimilarityTabOperator.class)
|
.get(SimilarityTabOperator.class)
|
||||||
.map(SimilarityTabOperator::getConfig)
|
.map(SimilarityTabOperator::getConfig)
|
||||||
.orElse(new SimilarityConfig.Builder().build());
|
.orElseGet(() -> new SimilarityConfig.Builder().build());
|
||||||
Sort sort =
|
Sort sort =
|
||||||
operatorRegistry.get(SortTabOperator.class).map(SortTabOperator::getSort).orElse(null);
|
operatorRegistry.get(SortTabOperator.class).map(SortTabOperator::getSort).orElse(null);
|
||||||
Set<String> fieldsToLoad =
|
Set<String> fieldsToLoad =
|
||||||
|
@ -562,12 +562,12 @@ public final class SearchPanelProvider implements SearchTabOperator {
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
.get(MLTTabOperator.class)
|
.get(MLTTabOperator.class)
|
||||||
.map(MLTTabOperator::getConfig)
|
.map(MLTTabOperator::getConfig)
|
||||||
.orElse(new MLTConfig.Builder().build());
|
.orElseGet(() -> new MLTConfig.Builder().build());
|
||||||
Analyzer analyzer =
|
Analyzer analyzer =
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
.get(AnalysisTabOperator.class)
|
.get(AnalysisTabOperator.class)
|
||||||
.map(AnalysisTabOperator::getCurrentAnalyzer)
|
.map(AnalysisTabOperator::getCurrentAnalyzer)
|
||||||
.orElse(new StandardAnalyzer());
|
.orElseGet(StandardAnalyzer::new);
|
||||||
Query query = searchModel.mltQuery(docNum, mltConfig, analyzer);
|
Query query = searchModel.mltQuery(docNum, mltConfig, analyzer);
|
||||||
Set<String> fieldsToLoad =
|
Set<String> fieldsToLoad =
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
|
@ -602,12 +602,12 @@ public final class SearchPanelProvider implements SearchTabOperator {
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
.get(QueryParserTabOperator.class)
|
.get(QueryParserTabOperator.class)
|
||||||
.map(QueryParserTabOperator::getConfig)
|
.map(QueryParserTabOperator::getConfig)
|
||||||
.orElse(new QueryParserConfig.Builder().build());
|
.orElseGet(() -> new QueryParserConfig.Builder().build());
|
||||||
Analyzer analyzer =
|
Analyzer analyzer =
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
.get(AnalysisTabOperator.class)
|
.get(AnalysisTabOperator.class)
|
||||||
.map(AnalysisTabOperator::getCurrentAnalyzer)
|
.map(AnalysisTabOperator::getCurrentAnalyzer)
|
||||||
.orElse(new StandardAnalyzer());
|
.orElseGet(StandardAnalyzer::new);
|
||||||
return searchModel.parseQuery(expr, df, analyzer, config, rewrite);
|
return searchModel.parseQuery(expr, df, analyzer, config, rewrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -457,7 +457,7 @@ public final class AddDocumentDialogFactory
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
.get(AnalysisTabOperator.class)
|
.get(AnalysisTabOperator.class)
|
||||||
.map(AnalysisTabOperator::getCurrentAnalyzer)
|
.map(AnalysisTabOperator::getCurrentAnalyzer)
|
||||||
.orElse(new StandardAnalyzer());
|
.orElseGet(StandardAnalyzer::new);
|
||||||
toolsModel.addDocument(doc, analyzer);
|
toolsModel.addDocument(doc, analyzer);
|
||||||
indexHandler.reOpen();
|
indexHandler.reOpen();
|
||||||
operatorRegistry
|
operatorRegistry
|
||||||
|
|
|
@ -163,7 +163,7 @@ public final class AnalysisImpl implements Analysis {
|
||||||
config
|
config
|
||||||
.getConfigDir()
|
.getConfigDir()
|
||||||
.map(path -> CustomAnalyzer.builder(FileSystems.getDefault().getPath(path)))
|
.map(path -> CustomAnalyzer.builder(FileSystems.getDefault().getPath(path)))
|
||||||
.orElse(CustomAnalyzer.builder());
|
.orElseGet(CustomAnalyzer::builder);
|
||||||
|
|
||||||
// set tokenizer
|
// set tokenizer
|
||||||
builder.withTokenizer(
|
builder.withTokenizer(
|
||||||
|
|
Loading…
Reference in New Issue