Skip to content

Commit 84b7c60

Browse files
authored
Remove unnecessary NoInlining, #931 (#1099)
1 parent ad5d70a commit 84b7c60

36 files changed

+47
-116
lines changed

src/Lucene.Net.Facet/DrillDownQuery.cs

-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ public DrillDownQuery(FacetsConfig config, Query baseQuery)
158158
/// Merges (ORs) a new path into an existing AND'd
159159
/// clause.
160160
/// </summary>
161-
[MethodImpl(MethodImplOptions.NoInlining)]
162161
private void Merge(string dim, string[] path)
163162
{
164163
int index = 0;

src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3087,7 +3087,6 @@ private static void RegisterToRemoveAfterSuite(FileSystemInfo f)
30873087
}
30883088
}
30893089

3090-
[MethodImpl(MethodImplOptions.NoInlining)]
30913090
protected string GetFullMethodName([CallerMemberName] string memberName = "")
30923091
{
30933092
return $"{this.GetType().Name}+{memberName}";

src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,10 @@ public override void Eval(MockDirectoryWrapper dir)
696696
{
697697
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
698698
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
699-
bool sawAppend = StackTraceHelper.DoesStackTraceContainMethod(nameof(FreqProxTermsWriterPerField), "Flush");
699+
// LUCENENET NOTE: This code seems incorrect in Lucene, as it checks for "Flush" regardless of type in the sawFlush case,
700+
// which will always be true if the first case is true. The name of the variable implies it checking for "Append"
701+
// but that is not a method on FreqProxTermsWriterPerField.
702+
bool sawAppend = StackTraceHelper.DoesStackTraceContainMethod(nameof(FreqProxTermsWriterPerField), nameof(FreqProxTermsWriterPerField.Flush));
700703
bool sawFlush = StackTraceHelper.DoesStackTraceContainMethod("Flush");
701704

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

10221025
if (m_doFail && foundMethod)
10231026
{
@@ -1088,8 +1091,8 @@ private class FailOnlyInCommit : Failure
10881091
{
10891092
internal bool failOnCommit, failOnDeleteFile;
10901093
internal readonly bool dontFailDuringGlobalFieldMap;
1091-
internal const string PREPARE_STAGE = "PrepareCommit";
1092-
internal const string FINISH_STAGE = "FinishCommit";
1094+
internal const string PREPARE_STAGE = nameof(SegmentInfos.PrepareCommit);
1095+
internal const string FINISH_STAGE = nameof(SegmentInfos.FinishCommit);
10931096
internal readonly string stage;
10941097

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

11091113
if (isInGlobalFieldMap && dontFailDuringGlobalFieldMap)
@@ -1618,8 +1622,8 @@ public virtual void TestTermVectorExceptions()
16181622

16191623
private class FailOnTermVectors : Failure
16201624
{
1621-
internal const string INIT_STAGE = "InitTermVectorsWriter";
1622-
internal const string AFTER_INIT_STAGE = "FinishDocument";
1625+
internal const string INIT_STAGE = nameof(TermVectorsConsumer.InitTermVectorsWriter);
1626+
internal const string AFTER_INIT_STAGE = nameof(TermVectorsConsumer.FinishDocument);
16231627
internal const string EXC_MSG = "FOTV";
16241628
internal readonly string stage;
16251629

src/Lucene.Net.Tests/Index/TestIndexWriterOnDiskFull.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,15 @@ public override void Eval(MockDirectoryWrapper dir)
573573

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

582582
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
583583
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
584-
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(LiveDocsFormat), "WriteLiveDocs") && !didFail2)
584+
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(LiveDocsFormat), nameof(LiveDocsFormat.WriteLiveDocs)) && !didFail2)
585585
{
586586
didFail2 = true;
587587
throw new IOException("fake disk full while writing LiveDocs");

src/Lucene.Net.Tests/Index/TestIndexWriterWithThreads.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public override void Eval(MockDirectoryWrapper dir)
502502
{
503503
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
504504
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
505-
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(DocFieldProcessor), "Flush"))
505+
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(DocFieldProcessor), nameof(DocFieldProcessor.Flush)))
506506
{
507507
if (onlyOnce)
508508
{

src/Lucene.Net.Tests/Index/TestPersistentSnapshotDeletionPolicy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public override void Eval(MockDirectoryWrapper dir)
161161
{
162162
// LUCENENET specific: for these to work in release mode, we have added [MethodImpl(MethodImplOptions.NoInlining)]
163163
// to each possible target of the StackTraceHelper. If these change, so must the attribute on the target methods.
164-
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(PersistentSnapshotDeletionPolicy), "Persist"))
164+
if (StackTraceHelper.DoesStackTraceContainMethod(nameof(PersistentSnapshotDeletionPolicy), nameof(PersistentSnapshotDeletionPolicy.Persist)))
165165
{
166166
throw new IOException("now fail on purpose");
167167
}

src/Lucene.Net/Codecs/LiveDocsFormat.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using System.Runtime.CompilerServices;
32

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

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

6462
/// <summary>
6563
/// Records all files in use by this <see cref="SegmentCommitInfo"/> into the files argument. </summary>
6664
public abstract void Files(SegmentCommitInfo info, ICollection<string> files);
6765
}
68-
}
66+
}

src/Lucene.Net/Codecs/StoredFieldsWriter.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ protected StoredFieldsWriter()
6565

6666
/// <summary>
6767
/// Called when a document and all its fields have been added. </summary>
68-
[MethodImpl(MethodImplOptions.NoInlining)]
6968
public virtual void FinishDocument()
7069
{
7170
}
@@ -78,7 +77,6 @@ public virtual void FinishDocument()
7877
/// Aborts writing entirely, implementation should remove
7978
/// any partially-written files, etc.
8079
/// </summary>
81-
[MethodImpl(MethodImplOptions.NoInlining)]
8280
public abstract void Abort();
8381

8482
/// <summary>
@@ -132,7 +130,7 @@ public virtual int Merge(MergeState mergeState)
132130
}
133131

134132
/// <summary>
135-
/// Sugar method for <see cref="StartDocument(int)"/> + <see cref="WriteField(FieldInfo, IIndexableField)"/>
133+
/// Sugar method for <see cref="StartDocument(int)"/> + <see cref="WriteField(FieldInfo, IIndexableField)"/>
136134
/// for every stored field in the document. </summary>
137135
protected void AddDocument<T1>(IEnumerable<T1> doc, FieldInfos fieldInfos) where T1 : Lucene.Net.Index.IIndexableField
138136
{
@@ -172,4 +170,4 @@ public void Dispose()
172170
/// </summary>
173171
protected abstract void Dispose(bool disposing);
174172
}
175-
}
173+
}

src/Lucene.Net/Codecs/TermVectorsWriter.cs

-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ protected TermVectorsWriter()
8080

8181
/// <summary>
8282
/// Called after a doc and all its fields have been added. </summary>
83-
[MethodImpl(MethodImplOptions.NoInlining)]
8483
public virtual void FinishDocument()
8584
{
8685
}
@@ -119,7 +118,6 @@ public virtual void FinishTerm()
119118
/// Aborts writing entirely, implementation should remove
120119
/// any partially-written files, etc.
121120
/// </summary>
122-
[MethodImpl(MethodImplOptions.NoInlining)]
123121
public abstract void Abort();
124122

125123
/// <summary>

src/Lucene.Net/Index/BinaryDocValuesWriter.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using System.Runtime.CompilerServices;
54

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

134-
[MethodImpl(MethodImplOptions.NoInlining)]
135133
public override void Abort()
136134
{
137135
}
@@ -175,4 +173,4 @@ private IEnumerable<BytesRef> GetBytesIterator(int maxDocParam)
175173
}
176174
}
177175
}
178-
}
176+
}

src/Lucene.Net/Index/DocConsumer.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Runtime.CompilerServices;
2-
31
namespace Lucene.Net.Index
42
{
53
/*
@@ -23,13 +21,10 @@ internal abstract class DocConsumer
2321
{
2422
public abstract void ProcessDocument(FieldInfos.Builder fieldInfos);
2523

26-
[MethodImpl(MethodImplOptions.NoInlining)]
2724
internal abstract void FinishDocument();
2825

29-
[MethodImpl(MethodImplOptions.NoInlining)]
3026
public abstract void Flush(SegmentWriteState state);
3127

32-
[MethodImpl(MethodImplOptions.NoInlining)]
3328
public abstract void Abort();
3429
}
35-
}
30+
}

src/Lucene.Net/Index/DocFieldConsumer.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using System.Runtime.CompilerServices;
32

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

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

3734
public abstract void StartDocument();
3835

3936
public abstract DocFieldConsumerPerField AddField(FieldInfo fi);
4037

41-
[MethodImpl(MethodImplOptions.NoInlining)]
4238
public abstract void FinishDocument();
4339
}
44-
}
40+
}

src/Lucene.Net/Index/DocFieldConsumerPerField.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Runtime.CompilerServices;
2-
31
namespace Lucene.Net.Index
42
{
53
/*
@@ -25,9 +23,8 @@ internal abstract class DocFieldConsumerPerField
2523
/// Processes all occurrences of a single field </summary>
2624
public abstract void ProcessFields(IIndexableField[] fields, int count);
2725

28-
[MethodImpl(MethodImplOptions.NoInlining)]
2926
internal abstract void Abort();
3027

3128
internal abstract FieldInfo FieldInfo { get; }
3229
}
33-
}
30+
}

src/Lucene.Net/Index/DocValuesFieldUpdates.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Lucene.Net.Diagnostics;
22
using System;
33
using System.Collections.Generic;
4-
using System.Diagnostics;
5-
using System.Runtime.CompilerServices;
64

75
namespace Lucene.Net.Index
86
{
@@ -104,7 +102,7 @@ internal virtual DocValuesFieldUpdates NewUpdates(string field, DocValuesFieldUp
104102

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

153150
/// <summary>
@@ -213,4 +210,4 @@ internal abstract class DocValuesFieldUpdatesIterator<T> : DocValuesFieldUpdates
213210
/// <inheritdoc/>
214211
public override abstract void Reset();
215212
}
216-
}
213+
}

src/Lucene.Net/Index/DocValuesProcessor.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Lucene.Net.Documents.Extensions;
44
using System;
55
using System.Collections.Generic;
6-
using System.Diagnostics;
76
using System.Runtime.CompilerServices;
87

98
namespace Lucene.Net.Index
@@ -49,7 +48,6 @@ public override void StartDocument()
4948
{
5049
}
5150

52-
[MethodImpl(MethodImplOptions.NoInlining)]
5351
internal override void FinishDocument()
5452
{
5553
}
@@ -233,4 +231,4 @@ public override void Abort()
233231
writers.Clear();
234232
}
235233
}
236-
}
234+
}

src/Lucene.Net/Index/DocValuesWriter.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Runtime.CompilerServices;
2-
31
namespace Lucene.Net.Index
42
{
53
/*
@@ -23,12 +21,10 @@ namespace Lucene.Net.Index
2321

2422
internal abstract class DocValuesWriter
2523
{
26-
[MethodImpl(MethodImplOptions.NoInlining)]
2724
public abstract void Abort();
2825

2926
public abstract void Finish(int numDoc);
3027

31-
[MethodImpl(MethodImplOptions.NoInlining)]
3228
public abstract void Flush(SegmentWriteState state, DocValuesConsumer consumer);
3329
}
34-
}
30+
}

src/Lucene.Net/Index/FreqProxTermsWriter.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ namespace Lucene.Net.Index
2929

3030
internal sealed class FreqProxTermsWriter : TermsHashConsumer
3131
{
32-
[MethodImpl(MethodImplOptions.NoInlining)]
3332
public override void Abort()
34-
{ }
33+
{
34+
}
3535

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

127-
[MethodImpl(MethodImplOptions.NoInlining)]
128127
internal override void FinishDocument(TermsHash termsHash)
129128
{
130129
}
@@ -133,4 +132,4 @@ internal override void StartDocument()
133132
{
134133
}
135134
}
136-
}
135+
}

src/Lucene.Net/Index/IMergeScheduler.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Runtime.CompilerServices;
32

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

2927
object Clone();

0 commit comments

Comments
 (0)