Skip to content

Commit 661213d

Browse files
author
linzhijun
committed
fix
1 parent a32d3b4 commit 661213d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

csharp/ToolGood.Algorithm/AlgorithmEngineHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ToolGood.Algorithm
1616
public static class AlgorithmEngineHelper
1717
{
1818
private static HashSet<string> _lexerSet;
19-
private static Lazy<Regex> unitRegex = new Lazy<Regex>(() => new Regex(@"[\s \(\)()\[\]<>]", RegexOptions.Compiled));
19+
private static Regex unitRegex;
2020

2121
private static HashSet<string> GetLexerSet()
2222
{
@@ -340,10 +340,10 @@ public static DiyNameInfo GetDiyNames(string exp)
340340
public static decimal UnitConversion(decimal src, string oldSrcUnit, string oldTarUnit, string name = null)
341341
{
342342
if (string.IsNullOrWhiteSpace(oldSrcUnit) || string.IsNullOrWhiteSpace(oldTarUnit)) { return src; }
343-
//if (unitRegex == null) {
344-
// unitRegex = new Regex(@"[\s \(\)()\[\]<>]", RegexOptions.Compiled);
345-
//}
346-
oldSrcUnit = unitRegex.Value.Replace(oldSrcUnit, "");
343+
if (unitRegex == null) {
344+
unitRegex = new Regex(@"[\s \(\)()\[\]<>]", RegexOptions.Compiled);
345+
}
346+
oldSrcUnit = unitRegex.Replace(oldSrcUnit, "");
347347
if (oldSrcUnit == oldTarUnit) { return src; }
348348

349349
if (DistanceConverter.Exists(oldSrcUnit, oldTarUnit)) {

0 commit comments

Comments
 (0)