Skip to content

Commit bf18b12

Browse files
committed
fix 简化
1 parent c90a8f3 commit bf18b12

2 files changed

Lines changed: 2 additions & 30 deletions

File tree

csharp/ToolGood.Algorithm/Internals/Visitors/CharUtil.cs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,7 @@ public static char StandardChar(char o)
2929
}
3030
return char.ToUpperInvariant(o);
3131
}
32-
33-
public static string StandardString(string s)
34-
{
35-
// 快速路径:检查是否需要转换
36-
bool needsConversion = false;
37-
for(int i = 0; i < s.Length; i++) {
38-
char c = s[i];
39-
if(c != StandardChar(c)) {
40-
needsConversion = true;
41-
break;
42-
}
43-
}
44-
if(!needsConversion) return s;
45-
46-
// 使用 string.Create 减少堆分配
47-
return string.Create(s.Length, s, (span, str) => {
48-
for(int i = 0; i < str.Length; i++) {
49-
span[i] = StandardChar(str[i]);
50-
}
51-
});
52-
}
53-
32+
5433
public static bool Equals(string left, char right)
5534
{
5635
if(left.Length != 1) return false;
@@ -73,13 +52,6 @@ public static bool Equals(string left, string right)
7352
return true;
7453
}
7554

76-
public static bool Equals(string left, string arg1, string arg2)
77-
{
78-
if(Equals(left, arg1)) return true;
79-
if(Equals(left, arg2)) return true;
80-
return false;
81-
}
82-
8355
public static bool Equals(string left, string arg1, string arg2, string arg3)
8456
{
8557
if(Equals(left, arg1)) return true;

csharp/ToolGood.Algorithm/Internals/Visitors/MathSplitVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public ConditionTree VisitAndOr_fun(mathParser.AndOr_funContext context)
1919
Nodes = new List<ConditionTree>()
2020
};
2121
var t = context.op.Text;
22-
if(CharUtil.Equals(t, "&&", "and")) {
22+
if(CharUtil.Equals(t, "&&")) {
2323
tree.Type = ConditionTreeType.And;
2424
} else {
2525
tree.Type = ConditionTreeType.Or;

0 commit comments

Comments
 (0)