This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 299e04766ed37af0b9b91affdac6a7e01bd81fa0 Author: Shad Storhaug <[email protected]> AuthorDate: Thu Jul 23 12:05:50 2020 +0700 PERFORMANCE: Lucene.Net.Index.FieldInfos: Changed Builder.FieldInfo() method to TryGetFieldInfo() to optimize check for value (see #261) --- src/Lucene.Net/Index/FieldInfos.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Lucene.Net/Index/FieldInfos.cs b/src/Lucene.Net/Index/FieldInfos.cs index 6f6c77d..59bdcbc 100644 --- a/src/Lucene.Net/Index/FieldInfos.cs +++ b/src/Lucene.Net/Index/FieldInfos.cs @@ -365,8 +365,8 @@ namespace Lucene.Net.Index private FieldInfo AddOrUpdateInternal(string name, int preferredFieldNumber, bool isIndexed, bool storeTermVector, bool omitNorms, bool storePayloads, IndexOptions indexOptions, DocValuesType docValues, DocValuesType normType) { - FieldInfo fi = FieldInfo(name); - if (fi == null) + // LUCENENET: Bypass FieldInfo method so we can access the quick boolean check + if (!TryGetFieldInfo(name, out FieldInfo fi) || fi is null) { // this field wasn't yet added to this in-RAM // segment's FieldInfo, so now we get a global @@ -410,11 +410,9 @@ namespace Lucene.Net.Index return AddOrUpdateInternal(fi.Name, fi.Number, fi.IsIndexed, fi.HasVectors, fi.OmitsNorms, fi.HasPayloads, fi.IndexOptions, fi.DocValuesType, fi.NormType); } - public FieldInfo FieldInfo(string fieldName) + public bool TryGetFieldInfo(string fieldName, out FieldInfo ret) // LUCENENET specific - changed from FieldInfo to TryGetFieldInfo { - FieldInfo ret; - byName.TryGetValue(fieldName, out ret); - return ret; + return byName.TryGetValue(fieldName, out ret); } public FieldInfos Finish()
