Skip to content

Commit dc222b2

Browse files
apogeeoakjonsequitur
authored andcommitted
Cache create table result.
1 parent 8565a27 commit dc222b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/System.CommandLine/Help/HelpBuilder.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,13 @@ protected virtual void AppendHelpItems(IReadOnlyCollection<HelpItem> helpItems)
238238
/// <returns>
239239
/// A table of strings whose elements are the projection of the collection with whitespace formatting removed.
240240
/// </returns>
241-
protected virtual IEnumerable<IReadOnlyList<string>> CreateTable<T>(IEnumerable<T> collection, Func<T, IEnumerable<string>> selector)
241+
protected virtual IReadOnlyList<IReadOnlyList<string>> CreateTable<T>(IEnumerable<T> collection, Func<T, IEnumerable<string>> selector)
242242
{
243243
return collection.Select(selector)
244244
.Select(row => row
245245
.Select(element => ShortenWhitespace(element))
246-
.ToArray());
246+
.ToList())
247+
.ToList();
247248
}
248249

249250
/// <summary>
@@ -737,9 +738,13 @@ private bool ShouldDisplayArgumentHelp(ICommand? command)
737738
private int GetConsoleWindowWidth(IConsole console)
738739
{
739740
if (console is SystemConsole systemConsole)
741+
{
740742
return systemConsole.GetConsoleWindowWidth();
743+
}
741744
else
745+
{
742746
return int.MaxValue;
747+
}
743748
}
744749

745750
private string ShortenWhitespace(string input)

0 commit comments

Comments
 (0)