You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2021/02/17 18:07:39 UTC

[lucenenet] branch master updated: Lucene.Net.Highlighter.VectorHighlight.FieldPhraseList::GetHashCode(): Switched to using J2N's TripleShift method, as it is clear by the comment the reason for the problem was the cast to uint instead of ulong

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


The following commit(s) were added to refs/heads/master by this push:
     new 3736ddc  Lucene.Net.Highlighter.VectorHighlight.FieldPhraseList::GetHashCode(): Switched to using J2N's TripleShift method, as it is clear by the comment the reason for the problem was the cast to uint instead of ulong
3736ddc is described below

commit 3736ddcd7542c049377ef2fc3ab398bc4b23c2e0
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Wed Feb 17 19:39:40 2021 +0700

    Lucene.Net.Highlighter.VectorHighlight.FieldPhraseList::GetHashCode(): Switched to using J2N's TripleShift method, as it is clear by the comment the reason for the problem was the cast to uint instead of ulong
---
 .../VectorHighlight/FieldPhraseList.cs                    | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/Lucene.Net.Highlighter/VectorHighlight/FieldPhraseList.cs b/src/Lucene.Net.Highlighter/VectorHighlight/FieldPhraseList.cs
index 692cd6d..e2afbce 100644
--- a/src/Lucene.Net.Highlighter/VectorHighlight/FieldPhraseList.cs
+++ b/src/Lucene.Net.Highlighter/VectorHighlight/FieldPhraseList.cs
@@ -1,4 +1,5 @@
-using Lucene.Net.Support;
+using J2N.Numerics;
+using Lucene.Net.Support;
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
@@ -415,20 +416,10 @@ namespace Lucene.Net.Search.VectorHighlight
                 result = prime * result + StartOffset;
                 result = prime * result + EndOffset;
                 long b = J2N.BitConversion.DoubleToInt64Bits(Boost);
-                result = prime * result + (int)(b ^ TripleShift(b, 32));
+                result = prime * result + (int)(b ^ b.TripleShift(32));
                 return result;
             }
 
-            // LUCENENET NOTE: For some reason the standard way of correcting the >>>
-            // operator (int)((uint)b >> 32) didn't work here. Got this solution from http://stackoverflow.com/a/6625912
-            // and it works just like in Java.
-            private static long TripleShift(long n, int s)
-            {
-                if (n >= 0)
-                    return n >> s;
-                return (n >> s) + (2 << ~s);
-            }
-
             public override bool Equals(object obj)
             {
                 if (this == obj)