lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [13/50] [abbrv] lucenenet git commit: Fixed more ushort usage issues and left some documentation comments as a reminder to always cast the ReadShort() return value to ushort to ensure it is positive.
Date Sun, 02 Oct 2016 14:35:31 GMT
Fixed more ushort usage issues and left some documentation comments as a reminder to always
cast the ReadShort() return value to ushort to ensure it is positive.


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

Branch: refs/heads/master
Commit: e5f884d648b427133e5526ec250b4d07bbbe1984
Parents: 83bfcbe
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Fri Sep 16 00:16:12 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Oct 2 17:44:19 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Store/ByteArrayDataInput.cs           |  4 ++++
 src/Lucene.Net.Core/Store/DataInput.cs                    |  6 +++++-
 .../Suggest/Analyzing/AnalyzingSuggester.cs               | 10 +++++-----
 .../Suggest/Analyzing/FreeTextSuggester.cs                |  4 ++--
 4 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e5f884d6/src/Lucene.Net.Core/Store/ByteArrayDataInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/ByteArrayDataInput.cs b/src/Lucene.Net.Core/Store/ByteArrayDataInput.cs
index 219ec4e..9ea2c5f 100644
--- a/src/Lucene.Net.Core/Store/ByteArrayDataInput.cs
+++ b/src/Lucene.Net.Core/Store/ByteArrayDataInput.cs
@@ -94,6 +94,10 @@ namespace Lucene.Net.Store
             Pos += (int)count;
         }
 
+        /// <summary>
+        /// LUCENENET NOTE: Important - always cast to ushort (System.UInt16) before using
to ensure
+        /// the value is positive!
+        /// </summary>
         public override short ReadShort()
         {
             return (short)(ushort)(((Bytes[Pos++] & 0xFF) << 8) | (Bytes[Pos++]
& 0xFF));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e5f884d6/src/Lucene.Net.Core/Store/DataInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/DataInput.cs b/src/Lucene.Net.Core/Store/DataInput.cs
index 5332223..5280e7e 100644
--- a/src/Lucene.Net.Core/Store/DataInput.cs
+++ b/src/Lucene.Net.Core/Store/DataInput.cs
@@ -80,7 +80,11 @@ namespace Lucene.Net.Store
         }
 
         /// <summary>
-        /// Reads two bytes and returns a short. </summary>
+        /// Reads two bytes and returns a short. 
+        /// 
+        /// LUCENENET NOTE: Important - always cast to ushort (System.UInt16) before using
to ensure
+        /// the value is positive!
+        /// </summary>
         /// <seealso cref= DataOutput#writeByte(byte) </seealso>
         public virtual short ReadShort()
         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e5f884d6/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingSuggester.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingSuggester.cs b/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingSuggester.cs
index 95b1b57..8b13969 100644
--- a/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingSuggester.cs
+++ b/src/Lucene.Net.Suggest/Suggest/Analyzing/AnalyzingSuggester.cs
@@ -356,13 +356,13 @@ namespace Lucene.Net.Search.Suggest.Analyzing
 
                 // First by analyzed form:
                 readerA.Reset(a.Bytes, a.Offset, a.Length);
-                scratchA.Length = readerA.ReadShort();
+                scratchA.Length = (ushort)readerA.ReadShort();
                 scratchA.Bytes = a.Bytes;
                 scratchA.Offset = readerA.Position;
 
                 readerB.Reset(b.Bytes, b.Offset, b.Length);
                 scratchB.Bytes = b.Bytes;
-                scratchB.Length = readerB.ReadShort();
+                scratchB.Length = (ushort)readerB.ReadShort();
                 scratchB.Offset = readerB.Position;
 
                 int cmp = scratchA.CompareTo(scratchB);
@@ -390,8 +390,8 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                 // Finally by surface form:
                 if (hasPayloads)
                 {
-                    scratchA.Length = readerA.ReadShort();
-                    scratchB.Length = readerB.ReadShort();
+                    scratchA.Length = (ushort)readerA.ReadShort();
+                    scratchB.Length = (ushort)readerB.ReadShort();
                     scratchA.Offset = readerA.Position;
                     scratchB.Offset = readerB.Position;
                 }
@@ -551,7 +551,7 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                     surface.Bytes = scratch.Bytes;
                     if (hasPayloads)
                     {
-                        surface.Length = input.ReadShort();
+                        surface.Length = (ushort)input.ReadShort();
                         surface.Offset = input.Position;
                     }
                     else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e5f884d6/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs b/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
index f562928..b4fe98b 100644
--- a/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
+++ b/src/Lucene.Net.Suggest/Suggest/Analyzing/FreeTextSuggester.cs
@@ -214,12 +214,12 @@ namespace Lucene.Net.Search.Suggest.Analyzing
                 readerB.Reset(b.Bytes, b.Offset, b.Length);
 
                 // By token:
-                scratchA.Length = readerA.ReadShort();
+                scratchA.Length = (ushort)readerA.ReadShort();
                 scratchA.Bytes = a.Bytes;
                 scratchA.Offset = readerA.Position;
 
                 scratchB.Bytes = b.Bytes;
-                scratchB.Length = readerB.ReadShort();
+                scratchB.Length = (ushort)readerB.ReadShort();
                 scratchB.Offset = readerB.Position;
 
                 int cmp = scratchA.CompareTo(scratchB);


Mime
View raw message