Skip to content

Commit

Permalink
Make local functions static where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Dec 6, 2019
1 parent 9fc8f1c commit 47e4f09
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Microsoft.ML.Core/Utilities/ThreadUtils.cs
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
Expand Up @@ -130,7 +130,7 @@ public static ILegacyDataLoader Create(IHostEnvironment env, Arguments args, IMu
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
Expand Up @@ -38,7 +38,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
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
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

0 comments on commit 47e4f09

Please sign in to comment.