diff --git a/src/Lucene.Net/Util/FixedBitSet.cs b/src/Lucene.Net/Util/FixedBitSet.cs index dc8f2700c0..f16d48d5e5 100644 --- a/src/Lucene.Net/Util/FixedBitSet.cs +++ b/src/Lucene.Net/Util/FixedBitSet.cs @@ -259,7 +259,7 @@ public int Cardinality() public bool Get(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, () => "index=" + index + ", numBits=" + numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index}, numBits={numBits}"); int i = index >> 6; // div 64 // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. @@ -270,7 +270,7 @@ public bool Get(int index) public void Set(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, () => "index=" + index + ", numBits=" + numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index}, numBits={numBits}"); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; @@ -279,7 +279,7 @@ public void Set(int index) public bool GetAndSet(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index}, numBits={numBits}"); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; @@ -290,7 +290,7 @@ public bool GetAndSet(int index) public void Clear(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index}, numBits={numBits}"); int wordNum = index >> 6; int bit = index & 0x03f; long bitmask = 1L << bit; @@ -299,7 +299,7 @@ public void Clear(int index) public bool GetAndClear(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index}, numBits={numBits}"); int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; @@ -314,7 +314,7 @@ public bool GetAndClear(int index) /// public int NextSetBit(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, () => "index=" + index + ", numBits=" + numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index}, numBits={numBits}"); int i = index >> 6; int subIndex = index & 0x3f; // index within the word long word = bits[i] >> subIndex; // skip all the bits to the right of index @@ -342,7 +342,7 @@ public int NextSetBit(int index) /// public int PrevSetBit(int index) { - if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, () => "index=" + index + " numBits=" + numBits); + if (Debugging.AssertsEnabled) Debugging.Assert(index >= 0 && index < numBits, $"index={index} numBits={numBits}"); int i = index >> 6; int subIndex = index & 0x3f; // index within the word long word = (bits[i] << (63 - subIndex)); // skip all the bits to the left of index @@ -405,7 +405,7 @@ public void Or(FixedBitSet other) private void Or(long[] otherArr, int otherNumWords) { - if (Debugging.AssertsEnabled) Debugging.Assert(otherNumWords <= numWords, () => "numWords=" + numWords + ", otherNumWords=" + otherNumWords); + if (Debugging.AssertsEnabled) Debugging.Assert(otherNumWords <= numWords, $"numWords={numWords}, otherNumWords={otherNumWords}"); long[] thisArr = this.bits; int pos = Math.Min(numWords, otherNumWords); while (--pos >= 0) @@ -418,7 +418,7 @@ private void Or(long[] otherArr, int otherNumWords) /// this = this XOR other public void Xor(FixedBitSet other) { - if (Debugging.AssertsEnabled) Debugging.Assert(other.numWords <= numWords, () => "numWords=" + numWords + ", other.numWords=" + other.numWords); + if (Debugging.AssertsEnabled) Debugging.Assert(other.numWords <= numWords, $"numWords={numWords}, other.numWords={other.numWords}"); long[] thisBits = this.bits; long[] otherBits = other.bits; int pos = Math.Min(numWords, other.numWords); @@ -663,8 +663,8 @@ public void Clear(int startIndex, int endIndex) { if (Debugging.AssertsEnabled) { - Debugging.Assert(startIndex >= 0 && startIndex < numBits, () => "startIndex=" + startIndex + ", numBits=" + numBits); - Debugging.Assert(endIndex >= 0 && endIndex <= numBits, () => "endIndex=" + endIndex + ", numBits=" + numBits); + Debugging.Assert(startIndex >= 0 && startIndex < numBits, $"startIndex={startIndex}, numBits={numBits}"); + Debugging.Assert(endIndex >= 0 && endIndex <= numBits, $"endIndex={endIndex}, numBits={numBits}"); } if (endIndex <= startIndex) {