Lucene.Net.Hightlighter.Highlight.QueryTermScorer: Replaced HashMap with Dictionary.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/6ffeb419 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/6ffeb419 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/6ffeb419 Branch: refs/heads/api-work Commit: 6ffeb41961134500d722643497b5fa7e4801fb36 Parents: 747a4d7 Author: Shad Storhaug <[email protected]> Authored: Mon Mar 20 03:41:03 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Mon Mar 20 03:41:03 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Highlighter/Highlight/QueryTermScorer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6ffeb419/src/Lucene.Net.Highlighter/Highlight/QueryTermScorer.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Highlighter/Highlight/QueryTermScorer.cs b/src/Lucene.Net.Highlighter/Highlight/QueryTermScorer.cs index 8b77cd2..46e3241 100644 --- a/src/Lucene.Net.Highlighter/Highlight/QueryTermScorer.cs +++ b/src/Lucene.Net.Highlighter/Highlight/QueryTermScorer.cs @@ -38,7 +38,7 @@ namespace Lucene.Net.Search.Highlight private float totalScore = 0; private float maxTermWeight = 0; - private HashMap<string, WeightedTerm> termsToFind; + private IDictionary<string, WeightedTerm> termsToFind; private ICharTermAttribute termAtt; @@ -81,7 +81,7 @@ namespace Lucene.Net.Search.Highlight public QueryTermScorer(WeightedTerm[] weightedTerms) { - termsToFind = new HashMap<string, WeightedTerm>(); + termsToFind = new Dictionary<string, WeightedTerm>(); for (int i = 0; i < weightedTerms.Length; i++) { WeightedTerm existingTerm; @@ -120,8 +120,8 @@ namespace Lucene.Net.Search.Highlight { string termText = termAtt.ToString(); - WeightedTerm queryTerm = termsToFind[termText]; - if (queryTerm == null) + WeightedTerm queryTerm; + if (!termsToFind.TryGetValue(termText, out queryTerm) || queryTerm == null) { // not a query term - return return 0;
