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 the shr.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.
Original report: https://github.com/apache/lucenenet/issues/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.