Skip to content

Make local functions static where applicable #4530

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

Merged
merged 1 commit into from
Dec 8, 2019
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
6 changes: 3 additions & 3 deletions src/Microsoft.ML.Core/Utilities/ThreadUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static Task Queue(Delegate threadStart, object state)
// Return the task.
return tcs.Task;

void CreateThread()
static void CreateThread()
{
// Create a new background thread to run the work.
var t = new Thread(() =>
Expand Down Expand Up @@ -96,7 +96,7 @@ void CreateThread()
t.Start();
}

void Enqueue((Delegate, object, TaskCompletionSource<bool>) item)
static void Enqueue((Delegate, object, TaskCompletionSource<bool>) item)
{
// Enqueue the work. If there are currently fewer threads waiting
// for work than there are work items in the queue, create another
Expand All @@ -120,7 +120,7 @@ void Enqueue((Delegate, object, TaskCompletionSource<bool>) item)
CreateThread();
}

bool TryDequeue(out (Delegate action, object state, TaskCompletionSource<bool> tcs) item)
static bool TryDequeue(out (Delegate action, object state, TaskCompletionSource<bool> tcs) item)
{
// Dequeues the next item if one is available. Before checking,
// the available thread count is increased, so that enqueuers can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static ILegacyDataLoader CreateCore(IHost host, ILegacyDataLoader srcLoa
if (Utils.Size(transformArgs) == 0)
return srcLoader;

string GetTagData(IComponentFactory<IDataView, IDataTransform> factory)
static string GetTagData(IComponentFactory<IDataView, IDataTransform> factory)
{
// When coming from the command line, preserve the string arguments.
// For other factories, we aren't able to get the string.
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.ML.Functional.Tests/DataTransformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void ExtensibilityAddAColumnAsAFunctionOfMultipleColumns()
data = mlContext.Data.TakeRows(data, numSamples);

// Create a stand-alone function to produce a random number.
float angiospermCosine(float petalWidth, float petalLength, float sepalWidth, float sepalLength)
static float angiospermCosine(float petalWidth, float petalLength, float sepalWidth, float sepalLength)
{
var petalMagnitude = Math.Sqrt(petalWidth * petalWidth + petalLength * petalLength);
var sepalMagnitude = Math.Sqrt(sepalWidth * sepalWidth + sepalLength * sepalLength);
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.ML.Functional.Tests/ModelFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void LoadModelAndExtractPredictor()
loadedTransformerModel1 = mlContext.Model.LoadWithDataLoader(fs, out var l);
}

void AssertIsGam(ITransformer trans)
static void AssertIsGam(ITransformer trans)
{
Assert.IsType<GamBinaryModelParameters>(
Assert.IsAssignableFrom<CalibratedModelParametersBase>(
Expand Down
4 changes: 2 additions & 2 deletions test/Microsoft.ML.Tests/Transformers/ConcatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void TestConcat()
}, new MultiFileSource(dataPath));
var data = loader.Load(source);

DataViewType GetType(DataViewSchema schema, string name)
static DataViewType GetType(DataViewSchema schema, string name)
{
Assert.True(schema.TryGetColumnIndex(name, out int cIdx), $"Could not find '{name}'");
return schema[cIdx].Type;
Expand Down Expand Up @@ -113,7 +113,7 @@ public void ConcatWithAliases()
}, new MultiFileSource(dataPath));
var data = loader.Load(source);

DataViewType GetType(DataViewSchema schema, string name)
static DataViewType GetType(DataViewSchema schema, string name)
{
Assert.True(schema.TryGetColumnIndex(name, out int cIdx), $"Could not find '{name}'");
return schema[cIdx].Type;
Expand Down