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 2dd70a16368443df9deda358f08b4663963fc050
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Jun 23 18:02:30 2020 +0700

    Lucene.Net.Util.OfflineSorter: Removed unnecessary calls to ElementAt() and 
Count() LINQ methods, fixed boxing issue with the Assert.AreEquals call when 
comparing files (addresses #295).
---
 src/Lucene.Net.Tests/Util/TestOfflineSorter.cs | 29 +++++++++++---------------
 src/Lucene.Net/Util/OfflineSorter.cs           |  7 +++----
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/src/Lucene.Net.Tests/Util/TestOfflineSorter.cs 
b/src/Lucene.Net.Tests/Util/TestOfflineSorter.cs
index 34c4a13..8c56a5a 100644
--- a/src/Lucene.Net.Tests/Util/TestOfflineSorter.cs
+++ b/src/Lucene.Net.Tests/Util/TestOfflineSorter.cs
@@ -1,9 +1,9 @@
+using J2N.Text;
+using Lucene.Net.Attributes;
+using NUnit.Framework;
 using System;
 using System.Collections.Generic;
 using System.IO;
-using NUnit.Framework;
-using Lucene.Net.Attributes;
-using J2N.Text;
 using Assert = Lucene.Net.TestFramework.Assert;
 
 namespace Lucene.Net.Util
@@ -157,23 +157,18 @@ namespace Lucene.Net.Util
             byte[] buf1 = new byte[64 * 1024];
             byte[] buf2 = new byte[64 * 1024];
             int len;
-            //DataInputStream is1 = new DataInputStream(new 
FileInputStream(golden));
-            //DataInputStream is2 = new DataInputStream(new 
FileInputStream(sorted));
             using (Stream is1 = golden.Open(FileMode.Open, FileAccess.Read, 
FileShare.Delete))
+            using (Stream is2 = sorted.Open(FileMode.Open, FileAccess.Read, 
FileShare.Delete))
             {
-                using (Stream is2 = sorted.Open(FileMode.Open, 
FileAccess.Read, FileShare.Delete))
+                while ((len = is1.Read(buf1, 0, buf1.Length)) > 0)
                 {
-                    while ((len = is1.Read(buf1, 0, buf1.Length)) > 0)
-                    {
-                        is2.Read(buf2, 0, len);
-                        // Refactored test to let NUnit test the byte array 
rather than iterate each byte
-                        //for (int i = 0; i < len; i++)
-                        //{
-                        //    Assert.AreEqual(buf1[i], buf2[i]);
-                        //}
-                        Assert.AreEqual(buf1, buf2);
-                    }
-                    //IOUtils.Close(is1, is2);
+                    is2.Read(buf2, 0, len);
+                    // Refactored test to let NUnit test the byte array rather 
than iterate each byte
+                    //for (int i = 0; i < len; i++)
+                    //{
+                    //    Assert.AreEqual(buf1[i], buf2[i]);
+                    //}
+                    Assert.AreEqual(buf1, buf2);
                 }
             }
         }
diff --git a/src/Lucene.Net/Util/OfflineSorter.cs 
b/src/Lucene.Net/Util/OfflineSorter.cs
index 07910f2..f1c7a54 100644
--- a/src/Lucene.Net/Util/OfflineSorter.cs
+++ b/src/Lucene.Net/Util/OfflineSorter.cs
@@ -5,7 +5,6 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
 using System.IO;
-using System.Linq;
 using System.Text;
 
 namespace Lucene.Net.Util
@@ -396,13 +395,13 @@ namespace Lucene.Net.Util
 
             var @out = new ByteSequencesWriter(outputFile);
 
-            PriorityQueue<FileAndTop> queue = new 
PriorityQueueAnonymousInnerClassHelper(this, merges.Count());
+            PriorityQueue<FileAndTop> queue = new 
PriorityQueueAnonymousInnerClassHelper(this, merges.Count);
 
-            var streams = new ByteSequencesReader[merges.Count()];
+            var streams = new ByteSequencesReader[merges.Count];
             try
             {
                 // Open streams and read the top for each file
-                for (int i = 0; i < merges.Count(); i++)
+                for (int i = 0; i < merges.Count; i++)
                 {
                     streams[i] = new ByteSequencesReader(merges[i]);
                     byte[] line = streams[i].Read();

Reply via email to