lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject lucenenet git commit: More cleanup
Date Sun, 01 Feb 2015 12:24:10 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 3fb54eeb7 -> bef6b9d04


More cleanup


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

Branch: refs/heads/master
Commit: bef6b9d043d606181b993f46be2fa3f1488fa769
Parents: 3fb54ee
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Sun Feb 1 14:23:40 2015 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Sun Feb 1 14:23:40 2015 +0200

----------------------------------------------------------------------
 .../Codecs/Lucene3x/Lucene3xFields.cs           |  8 ++--
 .../Codecs/Lucene3x/Lucene3xNormsProducer.cs    |  2 +-
 .../Lucene45/Lucene45DocValuesConsumer.cs       |  2 +-
 src/Lucene.Net.Core/Index/DocTermOrds.cs        | 45 +++++++++-----------
 src/Lucene.Net.Core/Search/FieldCacheImpl.cs    | 11 ++---
 src/Lucene.Net.Core/Util/ArrayUtil.cs           |  2 +-
 6 files changed, 30 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bef6b9d0/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
index fed442d..296c1fe 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
@@ -299,12 +299,12 @@ namespace Lucene.Net.Codecs.Lucene3x
 
             internal SegmentTermEnum SeekTermEnum;
 
-            internal static readonly sbyte UTF8_NON_BMP_LEAD = unchecked((sbyte)0xf0);
-            internal static readonly sbyte UTF8_HIGH_BMP_LEAD = unchecked((sbyte)0xee);
+            private const sbyte UTF8_NON_BMP_LEAD = unchecked((sbyte) 0xf0);
+            private const sbyte UTF8_HIGH_BMP_LEAD = unchecked((sbyte) 0xee);
 
             // Returns true if the unicode char is "after" the
             // surrogates in UTF16, ie >= U+E000 and <= U+FFFF:
-            private bool IsHighBMPChar(byte[] b, int idx)
+            private static bool IsHighBMPChar(byte[] b, int idx)
             {
                 return (((sbyte)b[idx]) & UTF8_HIGH_BMP_LEAD) == UTF8_HIGH_BMP_LEAD;
             }
@@ -312,7 +312,7 @@ namespace Lucene.Net.Codecs.Lucene3x
             // Returns true if the unicode char in the UTF8 byte
             // sequence starting at idx encodes a char outside of
             // BMP (ie what would be a surrogate pair in UTF16):
-            private bool IsNonBMPChar(byte[] b, int idx)
+            private static bool IsNonBMPChar(byte[] b, int idx)
             {
                 return (((sbyte)b[idx]) & UTF8_NON_BMP_LEAD) == UTF8_NON_BMP_LEAD;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bef6b9d0/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
index 6c7abcc..94ace4e 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Codecs.Lucene3x
     {
         /// <summary>
         /// norms header placeholder </summary>
-        internal static readonly sbyte[] NORMS_HEADER = new sbyte[] { (sbyte)'N', (sbyte)'R',
(sbyte)'M', -1 };
+        internal static readonly sbyte[] NORMS_HEADER = { (sbyte)'N', (sbyte)'R', (sbyte)'M',
-1 };
 
         /// <summary>
         /// Extension of norms file </summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bef6b9d0/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesConsumer.cs b/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesConsumer.cs
index 74c1f25..c4749d4 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesConsumer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesConsumer.cs
@@ -581,7 +581,7 @@ catch (System.IO.IOException)
 throw;
 }
 
-bytesRef.Bytes = (sbyte[])(Array)buffer;
+bytesRef.Bytes = buffer;
 bytesRef.Offset = 0;
 bytesRef.Length = output.Position;
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bef6b9d0/src/Lucene.Net.Core/Index/DocTermOrds.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/DocTermOrds.cs b/src/Lucene.Net.Core/Index/DocTermOrds.cs
index bc1ec9f..50bca35 100644
--- a/src/Lucene.Net.Core/Index/DocTermOrds.cs
+++ b/src/Lucene.Net.Core/Index/DocTermOrds.cs
@@ -192,13 +192,7 @@ namespace Lucene.Net.Index
             }
             if (Tnums != null)
             {
-                foreach (sbyte[] arr in Tnums)
-                {
-                    if (arr != null)
-                    {
-                        sz += arr.Length;
-                    }
-                }
+                sz = Tnums.Where(arr => arr != null).Aggregate(sz, (current, arr) =>
current + arr.Length);
             }
             Memsz = sz;
             return sz;
@@ -343,7 +337,7 @@ namespace Lucene.Net.Index
             int maxDoc = reader.MaxDoc;
             int[] index = new int[maxDoc]; // immediate term numbers, or the index into the
byte[] representing the last number
             int[] lastTerm = new int[maxDoc]; // last term we saw for this document
-            sbyte[][] bytes = new sbyte[maxDoc][]; // list of term numbers for the doc (delta
encoded vInts)
+            var bytes = new sbyte[maxDoc][]; // list of term numbers for the doc (delta encoded
vInts)
 
             Fields fields = reader.Fields;
             if (fields == null)
@@ -376,7 +370,7 @@ namespace Lucene.Net.Index
 
             // we need a minimum of 9 bytes, but round up to 12 since the space would
             // be wasted with most allocators anyway.
-            sbyte[] tempArr = new sbyte[12];
+            var tempArr = new sbyte[12];
 
             //
             // enumerate all terms, and build an intermediate form of the un-inverted field.
@@ -472,7 +466,7 @@ namespace Lucene.Net.Index
                             // the doc-specific byte[] when building)
                             int pos = (int)((uint)val >> 8);
                             int ilen = VIntSize(delta);
-                            sbyte[] arr = bytes[doc];
+                            var arr = bytes[doc];
                             int newend = pos + ilen;
                             if (newend > arr.Length)
                             {
@@ -483,7 +477,7 @@ namespace Lucene.Net.Index
                                 // (how much space does a byte[] take up?  Is data preceded
by a 32 bit length only?
                                 // It should be safe to round up to the nearest 32 bits in
any case.
                                 int newLen = (newend + 3) & unchecked((int)0xfffffffc);
// 4 byte alignment
-                                sbyte[] newarr = new sbyte[newLen];
+                                var newarr = new sbyte[newLen];
                                 Array.Copy(arr, 0, newarr, 0, pos);
                                 arr = newarr;
                                 bytes[doc] = newarr;
@@ -578,8 +572,8 @@ namespace Lucene.Net.Index
 
                 for (int pass = 0; pass < 256; pass++)
                 {
-                    sbyte[] target = Tnums[pass];
-                    int pos = 0; // end in target;
+                    var target = Tnums[pass];
+                    var pos = 0; // end in target;
                     if (target != null)
                     {
                         pos = target.Length;
@@ -609,7 +603,7 @@ namespace Lucene.Net.Index
                                     // we only have 24 bits for the array index
                                     throw new InvalidOperationException("Too many values
for UnInvertedField faceting on field " + Field);
                                 }
-                                sbyte[] arr = bytes[doc];
+                                var arr = bytes[doc];
                                 /*
                                 for(byte b : arr) {
                                   //System.out.println("      b=" + Integer.toHexString((int)
b));
@@ -637,7 +631,7 @@ namespace Lucene.Net.Index
                                     {
                                         newlen <<= 1;
                                     }
-                                    sbyte[] newtarget = new sbyte[newlen];
+                                    var newtarget = new sbyte[newlen];
                                     Array.Copy(target, 0, newtarget, 0, pos);
                                     target = newtarget;
                                 }
@@ -650,7 +644,7 @@ namespace Lucene.Net.Index
                     // shrink array
                     if (pos < target.Length)
                     {
-                        sbyte[] newtarget = new sbyte[pos];
+                        var newtarget = new sbyte[pos];
                         Array.Copy(target, 0, newtarget, 0, pos);
                         target = newtarget;
                     }
@@ -701,8 +695,7 @@ namespace Lucene.Net.Index
         // a single switch on the size
         private static int WriteInt(int x, sbyte[] arr, int pos)
         {
-            int a;
-            a = ((int)((uint)x >> (7 * 4)));
+            var a = ((int)((uint)x >> (7 * 4)));
             if (a != 0)
             {
                 arr[pos++] = unchecked((sbyte)(a | 0x80));
@@ -956,18 +949,18 @@ namespace Lucene.Net.Index
         {
             private readonly DocTermOrds OuterInstance;
 
-            internal readonly AtomicReader Reader;
-            internal readonly TermsEnum Te; // used internally for lookupOrd() and lookupTerm()
+            private readonly AtomicReader Reader;
+            private readonly TermsEnum Te; // used internally for lookupOrd() and lookupTerm()
 
             // currently we read 5 at a time (using the logic of the old iterator)
-            internal readonly int[] Buffer = new int[5];
+            private readonly int[] Buffer = new int[5];
 
-            internal int BufferUpto;
-            internal int BufferLength;
+            private int BufferUpto;
+            private int BufferLength;
 
-            internal int Tnum;
-            internal int Upto;
-            internal sbyte[] Arr;
+            private int Tnum;
+            private int Upto;
+            private sbyte[] Arr;
 
             internal Iterator(DocTermOrds outerInstance, AtomicReader reader)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bef6b9d0/src/Lucene.Net.Core/Search/FieldCacheImpl.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldCacheImpl.cs b/src/Lucene.Net.Core/Search/FieldCacheImpl.cs
index 2434835..7f9e301 100644
--- a/src/Lucene.Net.Core/Search/FieldCacheImpl.cs
+++ b/src/Lucene.Net.Core/Search/FieldCacheImpl.cs
@@ -561,7 +561,7 @@ namespace Lucene.Net.Search
 
                 values = new sbyte[maxDoc];
 
-                Uninvert u = new UninvertAnonymousInnerClassHelper(this, values, parser);
+                Uninvert u = new UninvertAnonymousInnerClassHelper(values, parser);
 
                 u.DoUninvert(reader, key.Field, setDocsWithField);
 
@@ -575,14 +575,11 @@ namespace Lucene.Net.Search
 
             private class UninvertAnonymousInnerClassHelper : Uninvert
             {
-                private readonly ByteCache OuterInstance;
-
-                private sbyte[] Values;
-                private FieldCache.IByteParser Parser;
+                private readonly sbyte[] Values;
+                private readonly FieldCache.IByteParser Parser;
 
-                public UninvertAnonymousInnerClassHelper(ByteCache outerInstance, sbyte[]
values, FieldCache.IByteParser parser)
+                public UninvertAnonymousInnerClassHelper(sbyte[] values, FieldCache.IByteParser
parser)
                 {
-                    this.OuterInstance = outerInstance;
                     this.Values = values;
                     this.Parser = parser;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/bef6b9d0/src/Lucene.Net.Core/Util/ArrayUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/ArrayUtil.cs b/src/Lucene.Net.Core/Util/ArrayUtil.cs
index 031169a..02e007d 100644
--- a/src/Lucene.Net.Core/Util/ArrayUtil.cs
+++ b/src/Lucene.Net.Core/Util/ArrayUtil.cs
@@ -420,7 +420,7 @@ namespace Lucene.Net.Util
             Debug.Assert(minSize >= 0, "size must be positive (got " + minSize + "): likely
integer overflow?");
             if (array.Length < minSize)
             {
-                sbyte[] newArray = new sbyte[Oversize(minSize, 1)];
+                var newArray = new sbyte[Oversize(minSize, 1)];
                 Array.Copy(array, 0, newArray, 0, array.Length);
                 return newArray;
             }


Mime
View raw message