lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [37/50] lucenenet git commit: Lucene.Net.Analysis.Common.Analysis.Util.CharArrayMap: Added using block to enumerator in GetHashCode()
Date Thu, 30 Mar 2017 18:00:32 GMT
Lucene.Net.Analysis.Common.Analysis.Util.CharArrayMap: Added using block to enumerator in GetHashCode()


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

Branch: refs/heads/api-work
Commit: 71318f0f5dca367b372bb4272ef43058e4902aea
Parents: 7fd381b
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Thu Mar 30 16:25:50 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Mar 30 16:25:50 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Util/CharArrayMap.cs                       | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/71318f0f/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
index 4a2e700..e006ea5 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/CharArrayMap.cs
@@ -781,12 +781,14 @@ namespace Lucene.Net.Analysis.Util
         public override int GetHashCode()
         {
             const int PRIME = 31; // arbitrary prime
-            int hash = PRIME; 
-            var iter = (EntryIterator)EntrySet().GetEnumerator();
-            while (iter.MoveNext())
+            int hash = PRIME;
+            using (var iter = (EntryIterator)EntrySet().GetEnumerator())
             {
-                hash = (hash * PRIME) ^ iter.Current.Key.GetHashCode();
-                hash = (hash * PRIME) ^ iter.Current.Value.GetHashCode();
+                while (iter.MoveNext())
+                {
+                    hash = (hash * PRIME) ^ iter.Current.Key.GetHashCode();
+                    hash = (hash * PRIME) ^ iter.Current.Value.GetHashCode();
+                }
             }
             return hash;
         }


Mime
View raw message