diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-25 13:16:25 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-25 13:16:25 -0400 |
commit | 0134f0b28d355766a17b1c9da89b8173f978d195 (patch) | |
tree | c9e493b217691cba7f9700ad9901441fc8bb4424 /src/SMAPI/Framework | |
parent | 68206e00478905960e2a1f37f974f088f56b5390 (diff) | |
download | SMAPI-0134f0b28d355766a17b1c9da89b8173f978d195.tar.gz SMAPI-0134f0b28d355766a17b1c9da89b8173f978d195.tar.bz2 SMAPI-0134f0b28d355766a17b1c9da89b8173f978d195.zip |
update release notes, refactor a bit (#474)
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/CommandManager.cs | 21 |
1 files changed, 9 insertions, 12 deletions
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 *********/ - /// <summary> - /// Parses a string into an array of arguments. - /// </summary> + /// <summary>Parse a string into command arguments.</summary> /// <param name="input">The string to parse.</param> private string[] ParseArgs(string input) { bool inQuotes = false; IList<string> args = new List<string>(); - IList<char> currentArg = new List<char>(); - 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(); } |