summaryrefslogtreecommitdiff
path: root/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-26 19:49:17 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-26 19:49:17 -0500
commit22a0a32b6d959946bfd80bf0ca9796378f36e0cd (patch)
tree4dc91461e2a06148c975d12d46986a6a9648e1ff /src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
parent1b905205a3073c56e29c46b5e57c4a9cb2ca5832 (diff)
downloadSMAPI-22a0a32b6d959946bfd80bf0ca9796378f36e0cd.tar.gz
SMAPI-22a0a32b6d959946bfd80bf0ca9796378f36e0cd.tar.bz2
SMAPI-22a0a32b6d959946bfd80bf0ca9796378f36e0cd.zip
refactor performance counter code
This commit performs some general refactoring, including... - avoid manually duplicating the event list; - rework the 'is important' event flag; - remove the new packages (Cyotek.Collections can be replaced with built-in types, and System.ValueTuple won't work in the Mono version used on Linux/Mac); - improve performance; - minor cleanup.
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
index 8f0d89ba..2b562a08 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/TrainerCommand.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
@@ -66,7 +66,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
/// <param name="data">The data to display.</param>
/// <param name="header">The table header.</param>
/// <param name="getRow">Returns a set of fields for a data value.</param>
- /// <param name="rightAlign">True to right-align the data, false for left-align. Default false.</param>
+ /// <param name="rightAlign">Whether to right-align the data.</param>
protected string GetTableString<T>(IEnumerable<T> data, string[] header, Func<T, string[]> getRow, bool rightAlign = false)
{
// get table data
@@ -93,19 +93,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
};
lines.AddRange(rows);
- if (rightAlign)
- {
- return string.Join(
- Environment.NewLine,
- lines.Select(line => string.Join(" | ", line.Select((field, i) => field.PadLeft(widths[i], ' ')).ToArray())
- )
- );
- }
-
return string.Join(
Environment.NewLine,
- lines.Select(line => string.Join(" | ", line.Select((field, i) => field.PadRight(widths[i], ' ')).ToArray())
- )
+ lines.Select(line => string.Join(" | ",
+ line.Select((field, i) => rightAlign ? field.PadRight(widths[i], ' ') : field.PadLeft(widths[i], ' '))
+ ))
);
}
}