This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 535f8b81cf8d534a482cf39986d42df5b7d760a1 Author: rafael-aero <[email protected]> AuthorDate: Sat Oct 17 18:54:34 2020 +0200 Change Debugging.Assert usage to not allocate due to lambda capture --- src/Lucene.Net/Util/FixedBitSet.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 @@ namespace Lucene.Net.Util 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 @@ namespace Lucene.Net.Util 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 @@ namespace Lucene.Net.Util 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 @@ namespace Lucene.Net.Util 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 @@ namespace Lucene.Net.Util 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 @@ namespace Lucene.Net.Util /// </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 @@ namespace Lucene.Net.Util /// </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 @@ namespace Lucene.Net.Util 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 @@ namespace Lucene.Net.Util /// 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 @@ namespace Lucene.Net.Util { 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) {
