From 96403bc70766e11e6e35c6c08b0cb398e4fb34bc Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Sat, 23 Oct 2021 21:00:42 +0700 Subject: [PATCH] Lucene.Net.Sandbox.Queries.FuzzyLikeThisQuery: Compare using NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. See #269. --- src/Lucene.Net.Sandbox/Queries/FuzzyLikeThisQuery.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Lucene.Net.Sandbox/Queries/FuzzyLikeThisQuery.cs b/src/Lucene.Net.Sandbox/Queries/FuzzyLikeThisQuery.cs index 4607c43fa5..84e858f4dd 100644 --- a/src/Lucene.Net.Sandbox/Queries/FuzzyLikeThisQuery.cs +++ b/src/Lucene.Net.Sandbox/Queries/FuzzyLikeThisQuery.cs @@ -3,6 +3,7 @@ using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Search.Similarities; +using Lucene.Net.Support; using Lucene.Net.Util; using System; using System.Collections.Generic; @@ -362,15 +363,13 @@ public ScoreTermQueue(int size) /// (non-Javadoc) /// /// -#if NETFRAMEWORK - [MethodImpl(MethodImplOptions.NoOptimization)] // LUCENENET specific: comparing score equality fails in x86 on .NET Framework with optimizations enabled -#endif protected internal override bool LessThan(ScoreTerm termA, ScoreTerm termB) { - if (termA.Score == termB.Score) + // LUCENENET specific - compare bits rather than using equality operators to prevent these comparisons from failing in x86 in .NET Framework with optimizations enabled + if (NumericUtils.SingleToSortableInt32(termA.Score) == NumericUtils.SingleToSortableInt32(termB.Score)) return termA.Term.CompareTo(termB.Term) > 0; else - return termA.Score < termB.Score; + return NumericUtils.SingleToSortableInt32(termA.Score) < NumericUtils.SingleToSortableInt32(termB.Score); } }