Skip to content

Commit

Permalink
BREAKING: remove virtual call from the constructor (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
laimis authored Apr 8, 2023
1 parent 532f738 commit 0e2ecb2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Lucene.Net/Util/SentinelIntSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ namespace Lucene.Net.Util
/// <para/>
/// NOTE: This was SentinelIntSet in Lucene
/// <para/>
///
/// If you need to extend this class and subclass it, keep in mind that constructor
/// calls a private "ClearInternal" method and not virtual Clear. So if you need
/// to do some specific initialization in subclass constructor, call your own private
/// method with whatever custom initialization you need.
/// @lucene.internal
/// </summary>
public class SentinelInt32Set
Expand Down Expand Up @@ -84,12 +89,15 @@ public SentinelInt32Set(int size, int emptyVal)
keys = new int[tsize];
if (emptyVal != 0)
{
Clear();
ClearInternal(); // LUCENENET specific - calling private and not virtual method
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual void Clear()
public virtual void Clear() => ClearInternal();
// LUCENENET specific - S1699 - non-virtual method that can be
// called from the constructor
private void ClearInternal()
{
Arrays.Fill(keys, EmptyVal);
Count = 0;
Expand Down

0 comments on commit 0e2ecb2

Please sign in to comment.