From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Thu, 13 Feb 2020 13:10:04 +0000 (+0200) Subject: Remove unused variables and follow coding style (#677) X-Git-Tag: submit/tizen/20210909.063632~9800 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c4683fb3dd25db14a83e2463dfa194cd2146aa8c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove unused variables and follow coding style (#677) * Remove unused variables and follow coding style * Update BuildFolderSet.cs * Use StartNew method based on stephen feedback --- diff --git a/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolderSet.cs b/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolderSet.cs index dce465e..313cd58 100644 --- a/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolderSet.cs +++ b/src/coreclr/src/tools/ReadyToRun.SuperIlc/BuildFolderSet.cs @@ -97,7 +97,7 @@ namespace ReadyToRun.SuperIlc private void WriteJittedMethodSummary(StreamWriter logWriter) { - Dictionary>[] allMethodsPerModulePerCompiler = new Dictionary>[(int)CompilerIndex.Count]; + var allMethodsPerModulePerCompiler = new Dictionary>[(int)CompilerIndex.Count]; foreach (CompilerRunner runner in _compilerRunners) { @@ -108,7 +108,7 @@ namespace ReadyToRun.SuperIlc { for (int exeIndex = 0; exeIndex < folder.Executions.Count; exeIndex++) { - Dictionary>[] appMethodsPerModulePerCompiler = new Dictionary>[(int)CompilerIndex.Count]; + var appMethodsPerModulePerCompiler = new Dictionary>[(int)CompilerIndex.Count]; foreach (CompilerRunner runner in _compilerRunners) { appMethodsPerModulePerCompiler[(int)runner.Index] = new Dictionary>(); @@ -129,12 +129,11 @@ namespace ReadyToRun.SuperIlc return false; } - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); + Stopwatch stopwatch = Stopwatch.StartNew(); ResolveTestExclusions(); - List compilationsToRun = new List(); + var compilationsToRun = new List(); foreach (BuildFolder folder in FoldersToBuild) { @@ -154,10 +153,10 @@ namespace ReadyToRun.SuperIlc ParallelRunner.Run(compilationsToRun, _options.DegreeOfParallelism, _options.MeasurePerf); bool success = true; - List> failedCompilationsPerBuilder = new List>(); + var failedCompilationsPerBuilder = new List>(); int successfulCompileCount = 0; - List r2rDumpExecutionsToRun = new List(); + var r2rDumpExecutionsToRun = new List(); foreach (BuildFolder folder in FoldersToBuild) { @@ -247,8 +246,7 @@ namespace ReadyToRun.SuperIlc return true; } - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); + Stopwatch stopwatch = Stopwatch.StartNew(); string coreRoot = _options.CoreRootDirectory.FullName; string[] frameworkFolderFiles = Directory.GetFiles(coreRoot); @@ -263,13 +261,13 @@ namespace ReadyToRun.SuperIlc outputPath.RecreateDirectory(); } - List compilationsToRun = new List(); - List> compilationsPerRunner = new List>(); - List excludedAssemblies = new List(); + var compilationsToRun = new List(); + var compilationsPerRunner = new List>(); + var excludedAssemblies = new List(); if (_options.Composite) { - ProcessInfo[] processes = new ProcessInfo[(int)CompilerIndex.Count]; + var processes = new ProcessInfo[(int)CompilerIndex.Count]; foreach (CompilerRunner runner in frameworkRunners) { List inputFrameworkDlls = new List(); @@ -313,7 +311,7 @@ namespace ReadyToRun.SuperIlc _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; } @@ -322,12 +320,12 @@ namespace ReadyToRun.SuperIlc ParallelRunner.Run(compilationsToRun, _options.DegreeOfParallelism); - HashSet[] skipCopying = new HashSet[(int)CompilerIndex.Count]; + var skipCopying = new HashSet[(int)CompilerIndex.Count]; foreach (CompilerRunner runner in frameworkRunners) { skipCopying[(int)runner.Index] = new HashSet(StringComparer.OrdinalIgnoreCase); } - int[] failedCompilationsPerBuilder = new int[(int)CompilerIndex.Count]; + var failedCompilationsPerBuilder = new int[(int)CompilerIndex.Count]; int successfulCompileCount = 0; int failedCompileCount = 0; foreach (KeyValuePair kvp in compilationsPerRunner) @@ -461,9 +459,8 @@ namespace ReadyToRun.SuperIlc public bool Execute() { - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - List executionsToRun = new List(); + Stopwatch stopwatch = Stopwatch.StartNew(); + var executionsToRun = new List(); foreach (BuildFolder folder in FoldersToBuild) { @@ -517,8 +514,7 @@ namespace ReadyToRun.SuperIlc public bool Build() { - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); + Stopwatch stopwatch = Stopwatch.StartNew(); bool success = _options.Exe || Compile(); @@ -645,14 +641,14 @@ namespace ReadyToRun.SuperIlc 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) @@ -763,7 +759,7 @@ namespace ReadyToRun.SuperIlc if (foldersToBuild != 0) { int lineSize = 10 * _compilerRunners.Count() + 13 + 8; - string separator = new string('-', lineSize); + var separator = new string('-', lineSize); if (!_options.Exe) { @@ -862,7 +858,7 @@ namespace ReadyToRun.SuperIlc 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"); @@ -870,7 +866,7 @@ namespace ReadyToRun.SuperIlc logWriter.WriteLine(new string('-', title.Length)); foreach (KeyValuePair 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(" | "); @@ -883,7 +879,7 @@ namespace ReadyToRun.SuperIlc { string baseFolder = _options.InputDirectory.FullName; int baseOffset = baseFolder.Length + (baseFolder.Length > 0 && baseFolder[baseFolder.Length - 1] == Path.DirectorySeparatorChar ? 0 : 1); - HashSet folders = new HashSet(StringComparer.OrdinalIgnoreCase); + var folders = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (BuildFolder folder in FoldersToBuild) { string relativeFolder = ""; @@ -904,7 +900,7 @@ namespace ReadyToRun.SuperIlc return; } - List folderList = new List(folders); + var folderList = new List(folders); folderList.Sort(StringComparer.OrdinalIgnoreCase); logWriter.WriteLine(); logWriter.WriteLine("Folder statistics:"); @@ -1009,8 +1005,8 @@ namespace ReadyToRun.SuperIlc private void WriteExecutableSizeStatistics(StreamWriter logWriter) { - List sizeStats = new List(); - HashSet libraryHashes = new HashSet(StringComparer.OrdinalIgnoreCase); + var sizeStats = new List(); + var libraryHashes = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (BuildFolder folder in FoldersToBuild) { @@ -1205,7 +1201,7 @@ namespace ReadyToRun.SuperIlc public void WriteBuildLog(string buildLogPath) { - using (StreamWriter buildLogWriter = new StreamWriter(buildLogPath)) + using (var buildLogWriter = new StreamWriter(buildLogPath)) { WriteBuildStatistics(buildLogWriter); } @@ -1213,9 +1209,9 @@ namespace ReadyToRun.SuperIlc 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"); @@ -1224,7 +1220,7 @@ namespace ReadyToRun.SuperIlc 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) @@ -1332,7 +1328,7 @@ namespace ReadyToRun.SuperIlc 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); } @@ -1410,7 +1406,7 @@ namespace ReadyToRun.SuperIlc return; } - using (StreamWriter logWriter = new StreamWriter(fileName)) + using (var logWriter = new StreamWriter(fileName)) { foreach (KeyValuePair kvp in markerResults.OrderBy((kvp) => kvp.Key)) { @@ -1427,7 +1423,7 @@ namespace ReadyToRun.SuperIlc 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); @@ -1493,7 +1489,7 @@ namespace ReadyToRun.SuperIlc private void WriteFileListPerCompilationOutcome(string outputFileName, CompilationOutcome outcome) { - List filteredTestList = new List(); + var filteredTestList = new List(); foreach (BuildFolder folder in _buildFolders) { foreach (ProcessInfo[] compilation in folder.Compilations) @@ -1517,7 +1513,7 @@ namespace ReadyToRun.SuperIlc private void WriteFileListPerExecutionOutcome(string outputFileName, ExecutionOutcome outcome) { - List filteredTestList = new List(); + var filteredTestList = new List(); foreach (BuildFolder folder in _buildFolders) { foreach (ProcessInfo[] execution in folder.Executions)