Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary NoInlining, #931 #1099

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Lucene.Net.Facet/DrillDownQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public DrillDownQuery(FacetsConfig config, Query baseQuery)
/// Merges (ORs) a new path into an existing AND'd
/// clause.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
private void Merge(string dim, string[] path)
{
int index = 0;
Expand Down
1 change: 0 additions & 1 deletion src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3087,7 +3087,6 @@ private static void RegisterToRemoveAfterSuite(FileSystemInfo f)
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
protected string GetFullMethodName([CallerMemberName] string memberName = "")
{
return $"{this.GetType().Name}+{memberName}";
Expand Down
18 changes: 11 additions & 7 deletions src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,10 @@ public override void Eval(MockDirectoryWrapper dir)
{
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
bool sawAppend = StackTraceHelper.DoesStackTraceContainMethod(nameof(FreqProxTermsWriterPerField), "Flush");
// LUCENENET NOTE: This code seems incorrect in Lucene, as it checks for "Flush" regardless of type in the sawFlush case,
// which will always be true if the first case is true. The name of the variable implies it checking for "Append"
// but that is not a method on FreqProxTermsWriterPerField.
bool sawAppend = StackTraceHelper.DoesStackTraceContainMethod(nameof(FreqProxTermsWriterPerField), nameof(FreqProxTermsWriterPerField.Flush));
bool sawFlush = StackTraceHelper.DoesStackTraceContainMethod("Flush");

if (sawAppend && sawFlush && count++ >= 30)
Expand Down Expand Up @@ -1017,7 +1020,7 @@ public override void Eval(MockDirectoryWrapper dir)
{
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
bool foundMethod = StackTraceHelper.DoesStackTraceContainMethod(nameof(MockDirectoryWrapper), "Sync");
bool foundMethod = StackTraceHelper.DoesStackTraceContainMethod(nameof(MockDirectoryWrapper), nameof(MockDirectoryWrapper.Sync));

if (m_doFail && foundMethod)
{
Expand Down Expand Up @@ -1088,8 +1091,8 @@ private class FailOnlyInCommit : Failure
{
internal bool failOnCommit, failOnDeleteFile;
internal readonly bool dontFailDuringGlobalFieldMap;
internal const string PREPARE_STAGE = "PrepareCommit";
internal const string FINISH_STAGE = "FinishCommit";
internal const string PREPARE_STAGE = nameof(SegmentInfos.PrepareCommit);
internal const string FINISH_STAGE = nameof(SegmentInfos.FinishCommit);
internal readonly string stage;

public FailOnlyInCommit(bool dontFailDuringGlobalFieldMap, string stage)
Expand All @@ -1103,7 +1106,8 @@ public override void Eval(MockDirectoryWrapper dir)
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
bool isCommit = StackTraceHelper.DoesStackTraceContainMethod(nameof(SegmentInfos), stage);
bool isDelete = StackTraceHelper.DoesStackTraceContainMethod(nameof(MockDirectoryWrapper), "DeleteFile");
bool isDelete = StackTraceHelper.DoesStackTraceContainMethod(nameof(MockDirectoryWrapper), nameof(MockDirectoryWrapper.DeleteFile));
// LUCENENET NOTE: this method does not appear to exist anywhere, and is likely always false. It certainly doesn't exist on SegmentInfos.
bool isInGlobalFieldMap = StackTraceHelper.DoesStackTraceContainMethod(nameof(SegmentInfos), "WriteGlobalFieldMap");

if (isInGlobalFieldMap && dontFailDuringGlobalFieldMap)
Expand Down Expand Up @@ -1618,8 +1622,8 @@ public virtual void TestTermVectorExceptions()

private class FailOnTermVectors : Failure
{
internal const string INIT_STAGE = "InitTermVectorsWriter";
internal const string AFTER_INIT_STAGE = "FinishDocument";
internal const string INIT_STAGE = nameof(TermVectorsConsumer.InitTermVectorsWriter);
internal const string AFTER_INIT_STAGE = nameof(TermVectorsConsumer.FinishDocument);
internal const string EXC_MSG = "FOTV";
internal readonly string stage;

Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net.Tests/Index/TestIndexWriterOnDiskFull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,15 @@ public override void Eval(MockDirectoryWrapper dir)

// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(SegmentMerger), "MergeTerms") && !didFail1)
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(SegmentMerger), nameof(SegmentMerger.MergeTerms)) && !didFail1)
{
didFail1 = true;
throw new IOException("fake disk full during mergeTerms");
}

// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(LiveDocsFormat), "WriteLiveDocs") && !didFail2)
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(LiveDocsFormat), nameof(LiveDocsFormat.WriteLiveDocs)) && !didFail2)
{
didFail2 = true;
throw new IOException("fake disk full while writing LiveDocs");
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/Index/TestIndexWriterWithThreads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public override void Eval(MockDirectoryWrapper dir)
{
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(DocFieldProcessor), "Flush"))
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(DocFieldProcessor), nameof(DocFieldProcessor.Flush)))
{
if (onlyOnce)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public override void Eval(MockDirectoryWrapper dir)
{
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(PersistentSnapshotDeletionPolicy), "Persist"))
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(PersistentSnapshotDeletionPolicy), nameof(PersistentSnapshotDeletionPolicy.Persist)))
{
throw new IOException("now fail on purpose");
}
Expand Down
6 changes: 2 additions & 4 deletions src/Lucene.Net/Codecs/LiveDocsFormat.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Codecs
{
Expand Down Expand Up @@ -54,15 +53,14 @@ protected LiveDocsFormat()
public abstract IBits ReadLiveDocs(Directory dir, SegmentCommitInfo info, IOContext context);

/// <summary>
/// Persist live docs bits. Use
/// Persist live docs bits. Use
/// <see cref="SegmentCommitInfo.NextDelGen"/> to determine the
/// generation of the deletes file you should write to.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void WriteLiveDocs(IMutableBits bits, Directory dir, SegmentCommitInfo info, int newDelCount, IOContext context);

/// <summary>
/// Records all files in use by this <see cref="SegmentCommitInfo"/> into the files argument. </summary>
public abstract void Files(SegmentCommitInfo info, ICollection<string> files);
}
}
}
6 changes: 2 additions & 4 deletions src/Lucene.Net/Codecs/StoredFieldsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ protected StoredFieldsWriter()

/// <summary>
/// Called when a document and all its fields have been added. </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public virtual void FinishDocument()
{
}
Expand All @@ -78,7 +77,6 @@ public virtual void FinishDocument()
/// Aborts writing entirely, implementation should remove
/// any partially-written files, etc.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Abort();

/// <summary>
Expand Down Expand Up @@ -132,7 +130,7 @@ public virtual int Merge(MergeState mergeState)
}

/// <summary>
/// Sugar method for <see cref="StartDocument(int)"/> + <see cref="WriteField(FieldInfo, IIndexableField)"/>
/// Sugar method for <see cref="StartDocument(int)"/> + <see cref="WriteField(FieldInfo, IIndexableField)"/>
/// for every stored field in the document. </summary>
protected void AddDocument<T1>(IEnumerable<T1> doc, FieldInfos fieldInfos) where T1 : Lucene.Net.Index.IIndexableField
{
Expand Down Expand Up @@ -172,4 +170,4 @@ public void Dispose()
/// </summary>
protected abstract void Dispose(bool disposing);
}
}
}
2 changes: 0 additions & 2 deletions src/Lucene.Net/Codecs/TermVectorsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ protected TermVectorsWriter()

/// <summary>
/// Called after a doc and all its fields have been added. </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public virtual void FinishDocument()
{
}
Expand Down Expand Up @@ -119,7 +118,6 @@ public virtual void FinishTerm()
/// Aborts writing entirely, implementation should remove
/// any partially-written files, etc.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Abort();

/// <summary>
Expand Down
4 changes: 1 addition & 3 deletions src/Lucene.Net/Index/BinaryDocValuesWriter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
Expand Down Expand Up @@ -131,7 +130,6 @@ public override void Flush(SegmentWriteState state, DocValuesConsumer dvConsumer
dvConsumer.AddBinaryField(fieldInfo, GetBytesIterator(maxDoc));
}

[MethodImpl(MethodImplOptions.NoInlining)]
public override void Abort()
{
}
Expand Down Expand Up @@ -175,4 +173,4 @@ private IEnumerable<BytesRef> GetBytesIterator(int maxDocParam)
}
}
}
}
}
7 changes: 1 addition & 6 deletions src/Lucene.Net/Index/DocConsumer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
{
/*
Expand All @@ -23,13 +21,10 @@ internal abstract class DocConsumer
{
public abstract void ProcessDocument(FieldInfos.Builder fieldInfos);

[MethodImpl(MethodImplOptions.NoInlining)]
internal abstract void FinishDocument();

[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Flush(SegmentWriteState state);

[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Abort();
}
}
}
6 changes: 1 addition & 5 deletions src/Lucene.Net/Index/DocFieldConsumer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
{
Expand All @@ -26,19 +25,16 @@ internal abstract class DocFieldConsumer
/// Called when <see cref="DocumentsWriterPerThread"/> decides to create a new
/// segment
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
internal abstract void Flush(IDictionary<string, DocFieldConsumerPerField> fieldsToFlush, SegmentWriteState state);

/// <summary>
/// Called when an aborting exception is hit </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
internal abstract void Abort();

public abstract void StartDocument();

public abstract DocFieldConsumerPerField AddField(FieldInfo fi);

[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void FinishDocument();
}
}
}
5 changes: 1 addition & 4 deletions src/Lucene.Net/Index/DocFieldConsumerPerField.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
{
/*
Expand All @@ -25,9 +23,8 @@ internal abstract class DocFieldConsumerPerField
/// Processes all occurrences of a single field </summary>
public abstract void ProcessFields(IIndexableField[] fields, int count);

[MethodImpl(MethodImplOptions.NoInlining)]
internal abstract void Abort();

internal abstract FieldInfo FieldInfo { get; }
}
}
}
7 changes: 2 additions & 5 deletions src/Lucene.Net/Index/DocValuesFieldUpdates.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Lucene.Net.Diagnostics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
{
Expand Down Expand Up @@ -104,7 +102,7 @@ internal virtual DocValuesFieldUpdates NewUpdates(string field, DocValuesFieldUp

public override string ToString()
{
return "numericDVUpdates=" + string.Format(J2N.Text.StringFormatter.InvariantCulture, "{0}", numericDVUpdates) +
return "numericDVUpdates=" + string.Format(J2N.Text.StringFormatter.InvariantCulture, "{0}", numericDVUpdates) +
" binaryDVUpdates=" + string.Format(J2N.Text.StringFormatter.InvariantCulture, "{0}", binaryDVUpdates);
}
}
Expand Down Expand Up @@ -147,7 +145,6 @@ protected DocValuesFieldUpdates(string field, DocValuesFieldUpdatesType type)
/// segment which received updates while it was being merged. The given updates
/// should override whatever updates are in that instance.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Merge(DocValuesFieldUpdates other);

/// <summary>
Expand Down Expand Up @@ -213,4 +210,4 @@ internal abstract class DocValuesFieldUpdatesIterator<T> : DocValuesFieldUpdates
/// <inheritdoc/>
public override abstract void Reset();
}
}
}
4 changes: 1 addition & 3 deletions src/Lucene.Net/Index/DocValuesProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Lucene.Net.Documents.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
Expand Down Expand Up @@ -49,7 +48,6 @@ public override void StartDocument()
{
}

[MethodImpl(MethodImplOptions.NoInlining)]
internal override void FinishDocument()
{
}
Expand Down Expand Up @@ -233,4 +231,4 @@ public override void Abort()
writers.Clear();
}
}
}
}
6 changes: 1 addition & 5 deletions src/Lucene.Net/Index/DocValuesWriter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
{
/*
Expand All @@ -23,12 +21,10 @@ namespace Lucene.Net.Index

internal abstract class DocValuesWriter
{
[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Abort();

public abstract void Finish(int numDoc);

[MethodImpl(MethodImplOptions.NoInlining)]
public abstract void Flush(SegmentWriteState state, DocValuesConsumer consumer);
}
}
}
7 changes: 3 additions & 4 deletions src/Lucene.Net/Index/FreqProxTermsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ namespace Lucene.Net.Index

internal sealed class FreqProxTermsWriter : TermsHashConsumer
{
[MethodImpl(MethodImplOptions.NoInlining)]
public override void Abort()
{ }
{
}

// TODO: would be nice to factor out more of this, eg the
// FreqProxFieldMergeState, and code to visit all Fields
Expand Down Expand Up @@ -124,7 +124,6 @@ public override TermsHashConsumerPerField AddField(TermsHashPerField termsHashPe
return new FreqProxTermsWriterPerField(termsHashPerField, this, fieldInfo);
}

[MethodImpl(MethodImplOptions.NoInlining)]
internal override void FinishDocument(TermsHash termsHash)
{
}
Expand All @@ -133,4 +132,4 @@ internal override void StartDocument()
{
}
}
}
}
2 changes: 0 additions & 2 deletions src/Lucene.Net/Index/IMergeScheduler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.CompilerServices;

namespace Lucene.Net.Index
{
Expand All @@ -23,7 +22,6 @@ namespace Lucene.Net.Index
// LUCENENET specific
public interface IMergeScheduler : IDisposable // LUCENENET specific: Not implementing ICloneable per Microsoft's recommendation
{
[MethodImpl(MethodImplOptions.NoInlining)]
void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound);

object Clone();
Expand Down
Loading
Loading