lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [17/27] lucenenet git commit: Lucene.Net.Core.Support.Number: Removed bogus Signum() overload that was code duplication from sbyte.CompareTo(), long.CompareTo() and int.ComareTo() methods in .NET
Date Sun, 05 Feb 2017 16:51:52 GMT
Lucene.Net.Core.Support.Number: Removed bogus Signum() overload that was code duplication from
sbyte.CompareTo(), long.CompareTo() and int.ComareTo() methods in .NET


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

Branch: refs/heads/api-work
Commit: bab4adde0e689d4f463dbcff998a0bbe9bebec35
Parents: f383920
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Feb 5 17:23:36 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Feb 5 17:23:36 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Search/FieldComparator.cs | 29 ++++++++++++----------
 src/Lucene.Net.Core/Support/Number.cs         | 16 ------------
 2 files changed, 16 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bab4adde/src/Lucene.Net.Core/Search/FieldComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldComparator.cs b/src/Lucene.Net.Core/Search/FieldComparator.cs
index 0019688..06e04b3 100644
--- a/src/Lucene.Net.Core/Search/FieldComparator.cs
+++ b/src/Lucene.Net.Core/Search/FieldComparator.cs
@@ -374,8 +374,8 @@ namespace Lucene.Net.Search
 
             public override int Compare(int slot1, int slot2)
             {
-                //LUCENE TO-DO
-                return Number.Signum(values[slot1], values[slot2]);
+                // LUCENENET NOTE: Same logic as the Byte.compare() method in Java
+                return values[slot1].CompareTo(values[slot2]);
             }
 
             public override int CompareBottom(int doc)
@@ -387,8 +387,8 @@ namespace Lucene.Net.Search
                 {
                     v2 = m_missingValue.GetValueOrDefault();
                 }
-                //LUCENE TO-DO
-                return Number.Signum(bottom, v2);
+                // LUCENENET NOTE: Same logic as the Byte.compare() method in Java
+                return bottom.CompareTo(v2);
             }
 
             public override void Copy(int slot, int doc)
@@ -435,8 +435,8 @@ namespace Lucene.Net.Search
                 {
                     docValue = m_missingValue.GetValueOrDefault();
                 }
-                //LUCENE TO-DO
-                return Number.Signum(topValue, docValue);
+                // LUCENENET NOTE: Same logic as the Byte.compare() method in Java
+                return topValue.CompareTo(docValue);
             }
         }
 
@@ -637,8 +637,8 @@ namespace Lucene.Net.Search
 
             public override int Compare(int slot1, int slot2)
             {
-                //LUCENE TO-DO
-                return Number.Signum(values[slot1], values[slot2]);
+                // LUCENENET NOTE: Same logic as the Byte.compare() method in Java
+                return values[slot1].CompareTo(values[slot2]);
             }
 
             public override int CompareBottom(int doc)
@@ -651,8 +651,8 @@ namespace Lucene.Net.Search
                     v2 = m_missingValue.GetValueOrDefault();
                 }
 
-                //LUCENE TO-DO
-                return Number.Signum(bottom, v2);
+                // LUCENENET NOTE: Same logic as the Byte.compare() method in Java
+                return bottom.CompareTo(v2);
             }
 
             public override void Copy(int slot, int doc)
@@ -812,7 +812,8 @@ namespace Lucene.Net.Search
 
             public override int Compare(int slot1, int slot2)
             {
-                return Number.Signum(values[slot1], values[slot2]);
+                // LUCENENET NOTE: Same logic as the Long.compare() method in Java
+                return values[slot1].CompareTo(values[slot2]);
             }
 
             public override int CompareBottom(int doc)
@@ -827,7 +828,8 @@ namespace Lucene.Net.Search
                     v2 = m_missingValue.GetValueOrDefault();
                 }
 
-                return Number.Signum(bottom, v2);
+                // LUCENENET NOTE: Same logic as the Long.compare() method in Java
+                return bottom.CompareTo(v2);
             }
 
             public override void Copy(int slot, int doc)
@@ -1026,7 +1028,8 @@ namespace Lucene.Net.Search
             public override int CompareTop(int doc)
             {
                 int docValue = docBase + doc;
-                return Number.Signum(topValue, docValue);
+                // LUCENENET NOTE: Same logic as the Integer.compare() method in Java
+                return topValue.CompareTo(docValue);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bab4adde/src/Lucene.Net.Core/Support/Number.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Number.cs b/src/Lucene.Net.Core/Support/Number.cs
index 7201afe..d5f6ab0 100644
--- a/src/Lucene.Net.Core/Support/Number.cs
+++ b/src/Lucene.Net.Core/Support/Number.cs
@@ -361,22 +361,6 @@ namespace Lucene.Net.Support
             return a == 0 ? 0 : (int)(a / Math.Abs(a));
         }
 
-        public static int Signum(long a, long b)
-        {
-            if (a < b)
-            {
-                return -1;
-            }
-            else if (a > b)
-            {
-                return 1;
-            }
-            else
-            {
-                return 0;
-            }
-        }
-
         // Returns the number of 1-bits in the number
         public static int BitCount(int num)
         {


Mime
View raw message