lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [2/3] lucenenet git commit: Cleanup
Date Sat, 11 Apr 2015 18:48:22 GMT
Cleanup


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

Branch: refs/heads/master
Commit: 5091a1d333b4ff1e6efe3339e4415c83b1301447
Parents: 31a43f0
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Sat Apr 11 21:47:24 2015 +0300
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Sat Apr 11 21:47:24 2015 +0300

----------------------------------------------------------------------
 .../Function/ValueSources/DoubleFieldSource.cs               | 7 ++-----
 .../Function/ValueSources/FloatFieldSource.cs                | 7 ++-----
 src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs   | 7 ++-----
 .../Function/ValueSources/MaxFloatFunction.cs                | 8 ++------
 .../Function/ValueSources/MinFloatFunction.cs                | 8 ++------
 5 files changed, 10 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
index 95c74fd..ed6a71c 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
@@ -52,21 +52,18 @@ namespace Lucene.Net.Queries.Function.ValueSources
         {
             var arr = cache.GetDoubles(readerContext.AtomicReader, field, parser, true);
             var valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
-            return new DoubleDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
+            return new DoubleDocValuesAnonymousInnerClassHelper(this, arr, valid);
 
         }
 
         private class DoubleDocValuesAnonymousInnerClassHelper : DoubleDocValues
         {
-            private readonly DoubleFieldSource outerInstance;
-
             private readonly FieldCache.Doubles arr;
             private readonly Bits valid;
 
-            public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource outerInstance,
DoubleFieldSource @this, FieldCache.Doubles arr, Bits valid)
+            public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource @this, FieldCache.Doubles
arr, Bits valid)
                 : base(@this)
             {
-                this.outerInstance = outerInstance;
                 this.arr = arr;
                 this.valid = valid;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
index b3ba445..a396867 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
@@ -52,20 +52,17 @@ namespace Lucene.Net.Queries.Function.ValueSources
         {
             var arr = cache.GetFloats(readerContext.AtomicReader, field, parser, true);
             var valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
-            return new FloatDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
+            return new FloatDocValuesAnonymousInnerClassHelper(this, arr, valid);
         }
 
         private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
         {
-            private readonly FloatFieldSource outerInstance;
-
             private readonly FieldCache.Floats arr;
             private readonly Bits valid;
 
-            public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource outerInstance,
FloatFieldSource @this, FieldCache.Floats arr, Bits valid)
+            public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource @this, FieldCache.Floats
arr, Bits valid)
                 : base(@this)
             {
-                this.outerInstance = outerInstance;
                 this.arr = arr;
                 this.valid = valid;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
index 0eb8cad..5d405bc 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs
@@ -45,20 +45,17 @@ namespace Lucene.Net.Queries.Function.ValueSources
             FunctionValues trueVals = trueSource.GetValues(context, readerContext);
             FunctionValues falseVals = falseSource.GetValues(context, readerContext);
 
-            return new FunctionValuesAnonymousInnerClassHelper(this, ifVals, trueVals, falseVals);
+            return new FunctionValuesAnonymousInnerClassHelper(ifVals, trueVals, falseVals);
         }
 
         private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
         {
-            private readonly IfFunction outerInstance;
-
             private readonly FunctionValues ifVals;
             private readonly FunctionValues trueVals;
             private readonly FunctionValues falseVals;
 
-            public FunctionValuesAnonymousInnerClassHelper(IfFunction outerInstance, FunctionValues
ifVals, FunctionValues trueVals, FunctionValues falseVals)
+            public FunctionValuesAnonymousInnerClassHelper(FunctionValues ifVals, FunctionValues
trueVals, FunctionValues falseVals)
             {
-                this.outerInstance = outerInstance;
                 this.ifVals = ifVals;
                 this.trueVals = trueVals;
                 this.falseVals = falseVals;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
index 6e6126c..d126343 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 using System;
+using System.Linq;
 
 namespace Lucene.Net.Queries.Function.ValueSources
 {
@@ -39,12 +40,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
             {
                 return 0.0f;
             }
-            float val = float.NegativeInfinity;
-            foreach (FunctionValues vals in valsArr)
-            {
-                val = Math.Max(vals.FloatVal(doc), val);
-            }
-            return val;
+            return valsArr.Select(vals => vals.FloatVal(doc)).Concat(new[] {float.NegativeInfinity}).Max();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5091a1d3/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
index 3284b44..5c38c2d 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 using System;
+using System.Linq;
 
 namespace Lucene.Net.Queries.Function.ValueSources
 {
@@ -39,12 +40,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
             {
                 return 0.0f;
             }
-            float val = float.PositiveInfinity;
-            foreach (FunctionValues vals in valsArr)
-            {
-                val = Math.Min(vals.FloatVal(doc), val);
-            }
-            return val;
+            return valsArr.Select(vals => vals.FloatVal(doc)).Concat(new[] {float.PositiveInfinity}).Min();
         }
     }
 }
\ No newline at end of file


Mime
View raw message