Replace J2N.Numerics.BitOperation.TripleShift with >>> in C# 11 #115
Labels
good first issue
Good for newcomers
is:enhancement
New feature or request
pri:normal
up for grabs
This issue is open to be worked on by anyone
Milestone
Original report: apache/lucenenet#1006
Task description
There are various places throughout the codebase where we are using the
TripleShift
extension method from J2N to perform an unsigned right shift, since older versions of C# did not have this operator. C# 11 added the>>>
operator like Java has to do this, which gets translated directly to theshr.un
opcode, so should be more efficient than the several opcodes involved in the various TripleShift overloads, even if it is aggressively inlined. In addition, it will help make direct porting from Java easier.(Note: the aggressive inlining doesn't seem to be working in our published NuGet packages, as spot checking one example in BaseCharFilter still had a
call
operation to TripleShift, which is certainly going to be worse for performance than a single opcode.)I have confirmed this works on net462, our oldest target, with LangVersion set to 11, for all overloads that TripleShift supports.
Need to confirm that setting our LangVersion to 11 does not cause regressions elsewhere.
We should not be calling
TripleShift()
internally in J2N, however to avoid breaking API changes, we should leave these methods intact without changing them to>>>
.The text was updated successfully, but these errors were encountered: