Change Debugging.Assert usage to not allocate due to lambda capture
diff --git a/src/Lucene.Net/Util/FixedBitSet.cs b/src/Lucene.Net/Util/FixedBitSet.cs
index dc8f270..f16d48d 100644
--- a/src/Lucene.Net/Util/FixedBitSet.cs
+++ b/src/Lucene.Net/Util/FixedBitSet.cs
@@ -259,7 +259,7 @@
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 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 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 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 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 @@
/// </summary>
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 @@
/// </summary>
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 @@
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 @@
/// this = this XOR other </summary>
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 @@
{
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)
{