Skip to content

Commit

Permalink
Remove unused variables and follow coding style (dotnet#677)
Browse files Browse the repository at this point in the history
* Remove unused variables and follow coding style

* Update BuildFolderSet.cs

* Use StartNew method based on stephen feedback
  • Loading branch information
Youssef1313 authored Feb 13, 2020
1 parent 064d5a7 commit c4683fb
Showing 1 changed file with 36 additions and 40 deletions.
76 changes: 36 additions & 40 deletions src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolderSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public BuildFolderSet(

private void WriteJittedMethodSummary(StreamWriter logWriter)
{
Dictionary<string, HashSet<string>>[] allMethodsPerModulePerCompiler = new Dictionary<string, HashSet<string>>[(int)CompilerIndex.Count];
var allMethodsPerModulePerCompiler = new Dictionary<string, HashSet<string>>[(int)CompilerIndex.Count];

foreach (CompilerRunner runner in _compilerRunners)
{
Expand All @@ -108,7 +108,7 @@ private void WriteJittedMethodSummary(StreamWriter logWriter)
{
for (int exeIndex = 0; exeIndex < folder.Executions.Count; exeIndex++)
{
Dictionary<string, HashSet<string>>[] appMethodsPerModulePerCompiler = new Dictionary<string, HashSet<string>>[(int)CompilerIndex.Count];
var appMethodsPerModulePerCompiler = new Dictionary<string, HashSet<string>>[(int)CompilerIndex.Count];
foreach (CompilerRunner runner in _compilerRunners)
{
appMethodsPerModulePerCompiler[(int)runner.Index] = new Dictionary<string, HashSet<string>>();
Expand All @@ -129,12 +129,11 @@ public bool Compile()
return false;
}

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
Stopwatch stopwatch = Stopwatch.StartNew();

ResolveTestExclusions();

List<ProcessInfo> compilationsToRun = new List<ProcessInfo>();
var compilationsToRun = new List<ProcessInfo>();

foreach (BuildFolder folder in FoldersToBuild)
{
Expand All @@ -154,10 +153,10 @@ public bool Compile()
ParallelRunner.Run(compilationsToRun, _options.DegreeOfParallelism, _options.MeasurePerf);

bool success = true;
List<KeyValuePair<string, string>> failedCompilationsPerBuilder = new List<KeyValuePair<string, string>>();
var failedCompilationsPerBuilder = new List<KeyValuePair<string, string>>();
int successfulCompileCount = 0;

List<ProcessInfo> r2rDumpExecutionsToRun = new List<ProcessInfo>();
var r2rDumpExecutionsToRun = new List<ProcessInfo>();

foreach (BuildFolder folder in FoldersToBuild)
{
Expand Down Expand Up @@ -247,8 +246,7 @@ public bool CompileFramework()
return true;
}

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
Stopwatch stopwatch = Stopwatch.StartNew();

string coreRoot = _options.CoreRootDirectory.FullName;
string[] frameworkFolderFiles = Directory.GetFiles(coreRoot);
Expand All @@ -263,13 +261,13 @@ public bool CompileFramework()
outputPath.RecreateDirectory();
}

List<ProcessInfo> compilationsToRun = new List<ProcessInfo>();
List<KeyValuePair<string, ProcessInfo[]>> compilationsPerRunner = new List<KeyValuePair<string, ProcessInfo[]>>();
List<string> excludedAssemblies = new List<string>();
var compilationsToRun = new List<ProcessInfo>();
var compilationsPerRunner = new List<KeyValuePair<string, ProcessInfo[]>>();
var excludedAssemblies = new List<string>();

if (_options.Composite)
{
ProcessInfo[] processes = new ProcessInfo[(int)CompilerIndex.Count];
var processes = new ProcessInfo[(int)CompilerIndex.Count];
foreach (CompilerRunner runner in frameworkRunners)
{
List<string> inputFrameworkDlls = new List<string>();
Expand Down Expand Up @@ -313,7 +311,7 @@ public bool CompileFramework()
_frameworkExclusions[exclusion.SimpleName] = exclusion.Reason;
continue;
}
ProcessInfo compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, _options.CoreRootDirectory.FullName, new string[] { frameworkDll }));
var compilationProcess = new ProcessInfo(new CompilationProcessConstructor(runner, _options.CoreRootDirectory.FullName, new string[] { frameworkDll }));
compilationsToRun.Add(compilationProcess);
processes[(int)runner.Index] = compilationProcess;
}
Expand All @@ -322,12 +320,12 @@ public bool CompileFramework()

ParallelRunner.Run(compilationsToRun, _options.DegreeOfParallelism);

HashSet<string>[] skipCopying = new HashSet<string>[(int)CompilerIndex.Count];
var skipCopying = new HashSet<string>[(int)CompilerIndex.Count];
foreach (CompilerRunner runner in frameworkRunners)
{
skipCopying[(int)runner.Index] = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
}
int[] failedCompilationsPerBuilder = new int[(int)CompilerIndex.Count];
var failedCompilationsPerBuilder = new int[(int)CompilerIndex.Count];
int successfulCompileCount = 0;
int failedCompileCount = 0;
foreach (KeyValuePair<string, ProcessInfo[]> kvp in compilationsPerRunner)
Expand Down Expand Up @@ -461,9 +459,8 @@ private void AnalyzeMarker(string line, string marker, Dictionary<string, byte>

public bool Execute()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
List<ProcessInfo> executionsToRun = new List<ProcessInfo>();
Stopwatch stopwatch = Stopwatch.StartNew();
var executionsToRun = new List<ProcessInfo>();

foreach (BuildFolder folder in FoldersToBuild)
{
Expand Down Expand Up @@ -517,8 +514,7 @@ public bool Execute()

public bool Build()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
Stopwatch stopwatch = Stopwatch.StartNew();

bool success = _options.Exe || Compile();

Expand Down Expand Up @@ -645,14 +641,14 @@ private ExecutionOutcome GetExecutionOutcome(ProcessInfo execution)
private void WriteBuildStatistics(StreamWriter logWriter)
{
// The Count'th element corresponds to totals over all compiler runners used in the run
int[,] compilationOutcomes = new int[(int)CompilationOutcome.Count, (int)CompilerIndex.Count + 1];
int[,] executionOutcomes = new int[(int)ExecutionOutcome.Count, (int)CompilerIndex.Count + 1];
var compilationOutcomes = new int[(int)CompilationOutcome.Count, (int)CompilerIndex.Count + 1];
var executionOutcomes = new int[(int)ExecutionOutcome.Count, (int)CompilerIndex.Count + 1];
int totalCompilations = 0;
int totalExecutions = 0;

foreach (BuildFolder folder in FoldersToBuild)
{
bool[] compilationFailedPerRunner = new bool[(int)CompilerIndex.Count];
var compilationFailedPerRunner = new bool[(int)CompilerIndex.Count];
if (!_options.Exe)
{
foreach (ProcessInfo[] compilation in folder.Compilations)
Expand Down Expand Up @@ -763,7 +759,7 @@ private void WriteBuildStatistics(StreamWriter logWriter)
if (foldersToBuild != 0)
{
int lineSize = 10 * _compilerRunners.Count() + 13 + 8;
string separator = new string('-', lineSize);
var separator = new string('-', lineSize);

if (!_options.Exe)
{
Expand Down Expand Up @@ -862,15 +858,15 @@ private void WriteFrameworkExclusions(StreamWriter logWriter)
int keyLength = _frameworkExclusions.Keys.Max(key => key.Length);
const string SimpleNameTitle = "SIMPLE_NAME";
keyLength = Math.Max(keyLength, SimpleNameTitle.Length);
StringBuilder title = new StringBuilder();
var title = new StringBuilder();
title.Append(SimpleNameTitle);
title.Append(' ', keyLength - SimpleNameTitle.Length);
title.Append(" | REASON");
logWriter.WriteLine(title.ToString());
logWriter.WriteLine(new string('-', title.Length));
foreach (KeyValuePair<string, string> exclusion in _frameworkExclusions.OrderBy(kvp => kvp.Key, StringComparer.OrdinalIgnoreCase))
{
StringBuilder line = new StringBuilder();
var line = new StringBuilder();
line.Append(exclusion.Key);
line.Append(' ', keyLength - exclusion.Key.Length);
line.Append(" | ");
Expand All @@ -883,7 +879,7 @@ private void WritePerFolderStatistics(StreamWriter logWriter)
{
string baseFolder = _options.InputDirectory.FullName;
int baseOffset = baseFolder.Length + (baseFolder.Length > 0 && baseFolder[baseFolder.Length - 1] == Path.DirectorySeparatorChar ? 0 : 1);
HashSet<string> folders = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var folders = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (BuildFolder folder in FoldersToBuild)
{
string relativeFolder = "";
Expand All @@ -904,7 +900,7 @@ private void WritePerFolderStatistics(StreamWriter logWriter)
return;
}

List<string> folderList = new List<string>(folders);
var folderList = new List<string>(folders);
folderList.Sort(StringComparer.OrdinalIgnoreCase);
logWriter.WriteLine();
logWriter.WriteLine("Folder statistics:");
Expand Down Expand Up @@ -1009,8 +1005,8 @@ public ExeSizeInfo(string cpaotPath, long cpaotSize, string crossgenPath, long c

private void WriteExecutableSizeStatistics(StreamWriter logWriter)
{
List<ExeSizeInfo> sizeStats = new List<ExeSizeInfo>();
HashSet<string> libraryHashes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var sizeStats = new List<ExeSizeInfo>();
var libraryHashes = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

foreach (BuildFolder folder in FoldersToBuild)
{
Expand Down Expand Up @@ -1205,17 +1201,17 @@ private IEnumerable<ProcessInfo> EnumerateExecutions()

public void WriteBuildLog(string buildLogPath)
{
using (StreamWriter buildLogWriter = new StreamWriter(buildLogPath))
using (var buildLogWriter = new StreamWriter(buildLogPath))
{
WriteBuildStatistics(buildLogWriter);
}
}

public void WriteCombinedLog(string outputFile)
{
using (StreamWriter combinedLog = new StreamWriter(outputFile))
using (var combinedLog = new StreamWriter(outputFile))
{
StreamWriter[] perRunnerLog = new StreamWriter[(int)CompilerIndex.Count];
var perRunnerLog = new StreamWriter[(int)CompilerIndex.Count];
foreach (CompilerRunner runner in _compilerRunners)
{
string runnerLogPath = Path.ChangeExtension(outputFile, "-" + runner.CompilerName + ".log");
Expand All @@ -1224,7 +1220,7 @@ public void WriteCombinedLog(string outputFile)

foreach (BuildFolder folder in FoldersToBuild)
{
bool[] compilationErrorPerRunner = new bool[(int)CompilerIndex.Count];
var compilationErrorPerRunner = new bool[(int)CompilerIndex.Count];
if (!_options.Exe)
{
foreach (ProcessInfo[] compilation in folder.Compilations)
Expand Down Expand Up @@ -1332,7 +1328,7 @@ public void WriteLogs()
if (_options.Framework)
{
string frameworkExclusionsFile = Path.Combine(_options.OutputDirectory.FullName, "framework-exclusions-" + suffix);
using (StreamWriter writer = new StreamWriter(frameworkExclusionsFile))
using (var writer = new StreamWriter(frameworkExclusionsFile))
{
WriteFrameworkExclusions(writer);
}
Expand Down Expand Up @@ -1410,7 +1406,7 @@ private static void WriterMarkerLog(string fileName, Dictionary<string, byte> ma
return;
}

using (StreamWriter logWriter = new StreamWriter(fileName))
using (var logWriter = new StreamWriter(fileName))
{
foreach (KeyValuePair<string, byte> kvp in markerResults.OrderBy((kvp) => kvp.Key))
{
Expand All @@ -1427,7 +1423,7 @@ private static void WriterMarkerDiff(string fileName, Dictionary<string, byte> c
return;
}

using (StreamWriter logWriter = new StreamWriter(fileName))
using (var logWriter = new StreamWriter(fileName))
{
int cpaotCount = cpaot.Count();
logWriter.WriteLine("Objects queried by CPAOT: {0}", cpaotCount);
Expand Down Expand Up @@ -1493,7 +1489,7 @@ private static void WriterMarkerDiffSection(StreamWriter logWriter, string title

private void WriteFileListPerCompilationOutcome(string outputFileName, CompilationOutcome outcome)
{
List<string> filteredTestList = new List<string>();
var filteredTestList = new List<string>();
foreach (BuildFolder folder in _buildFolders)
{
foreach (ProcessInfo[] compilation in folder.Compilations)
Expand All @@ -1517,7 +1513,7 @@ private void WriteFileListPerCompilationOutcome(string outputFileName, Compilati

private void WriteFileListPerExecutionOutcome(string outputFileName, ExecutionOutcome outcome)
{
List<string> filteredTestList = new List<string>();
var filteredTestList = new List<string>();
foreach (BuildFolder folder in _buildFolders)
{
foreach (ProcessInfo[] execution in folder.Executions)
Expand Down

0 comments on commit c4683fb

Please sign in to comment.