Skip to content

Commit d33d117

Browse files
committed
Other: Optimizations.
1 parent 1376630 commit d33d117

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Program.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace CodeIngest;
44

5-
static class Program
5+
internal static class Program
66
{
7+
private static string[] SymbolsToCollapse { get; } = new[] {"<", "<=", "=", "==", "=>", ">", "!=", "(", ")", "{", "}", "[", "]", "-", "+", "*", "&", "%", "/", "<<", ">>", ";", ",", "||", "|", ":", "?", "|"};
8+
79
private static void Main(string[] args)
810
{
911
var switches = args.Where(o => o.StartsWith('-')).ToArray();
@@ -87,7 +89,7 @@ private static void Main(string[] args)
8789
}
8890

8991
if (verbose)
90-
Console.WriteLine($"{kvp.Key} ({lines.Sum(o => o.Length):N0} charactes -> {lines.Count:N0} lines)");
92+
Console.WriteLine($"{kvp.Key} ({lines.Sum(o => o.Length):N0} characters -> {lines.Count:N0} lines)");
9193
}
9294
}
9395

@@ -156,7 +158,7 @@ private static string GetCodeLine(string line)
156158
if (commentIndex >= 0)
157159
line = line[..commentIndex];
158160

159-
foreach (var expr in new[] {"<", "<=", "=", "==", "=>", ">", "!=", "(", ")", "{", "}", "-", "+", "*", "&", "%", "/", "<<", ">>", ";", ",", "||", "|", ":", "?", "|"})
161+
foreach (var expr in SymbolsToCollapse)
160162
line = line.Replace($"{expr} ", expr).Replace($" {expr}", expr);
161163

162164
while (line.Contains(" "))

0 commit comments

Comments
 (0)