lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [3/3] lucenenet git commit: Avoid KeyNotFoundException
Date Wed, 24 Dec 2014 22:56:33 GMT
Avoid KeyNotFoundException


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2221c6e0
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2221c6e0
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2221c6e0

Branch: refs/heads/master
Commit: 2221c6e0e81377c81bbda8f1d43c63e3693960e3
Parents: b7cf135
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Thu Dec 25 00:56:15 2014 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Thu Dec 25 00:56:15 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2221c6e0/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
index be54d1b..6b6ee77 100644
--- a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
+++ b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
@@ -580,8 +580,8 @@ namespace Lucene.Net.Queries.Mlt
                 var freq = (int)termsEnum.TotalTermFreq();
 
                 // increment frequency
-                var cnt = termFreqMap[term];
-                if (cnt == null)
+                Int cnt;
+                if (!termFreqMap.TryGetValue(term, out cnt))
                 {
                     cnt = new Int();
                     termFreqMap[term] = cnt;
@@ -627,8 +627,8 @@ namespace Lucene.Net.Queries.Mlt
                     }
 
                     // increment frequency
-                    Int cnt = termFreqMap[word];
-                    if (cnt == null)
+                    Int cnt;
+                    if (!termFreqMap.TryGetValue(word, out cnt))
                     {
                         termFreqMap[word] = new Int();
                     }


Mime
View raw message