From 0134f0b28d355766a17b1c9da89b8173f978d195 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 25 Apr 2018 13:16:25 -0400 Subject: update release notes, refactor a bit (#474) --- src/SMAPI/Framework/CommandManager.cs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Framework/CommandManager.cs b/src/SMAPI/Framework/CommandManager.cs index 0c48d8ec..f9651ed9 100644 --- a/src/SMAPI/Framework/CommandManager.cs +++ b/src/SMAPI/Framework/CommandManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; namespace StardewModdingAPI.Framework { @@ -103,31 +104,27 @@ namespace StardewModdingAPI.Framework /********* ** Private methods *********/ - /// - /// Parses a string into an array of arguments. - /// + /// Parse a string into command arguments. /// The string to parse. private string[] ParseArgs(string input) { bool inQuotes = false; IList args = new List(); - IList currentArg = new List(); - foreach (char c in input) + StringBuilder currentArg = new StringBuilder(); + foreach (char ch in input) { - if (c == '"') - { + if (ch == '"') inQuotes = !inQuotes; - } - else if (!inQuotes && char.IsWhiteSpace(c)) + else if (!inQuotes && char.IsWhiteSpace(ch)) { - args.Add(string.Concat(currentArg)); + args.Add(currentArg.ToString()); currentArg.Clear(); } else - currentArg.Add(c); + currentArg.Append(ch); } - args.Add(string.Concat(currentArg)); + args.Add(currentArg.ToString()); return args.Where(item => !string.IsNullOrWhiteSpace(item)).ToArray(); } -- cgit