Skip to content

Commit 747763a

Browse files
author
linzhijun
committed
fix
1 parent 32c8468 commit 747763a

File tree

2 files changed

+1216
-1215
lines changed

2 files changed

+1216
-1215
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 Regex unitRegex;
19+
private static Lazy<Regex> unitRegex = new Lazy<Regex>(() => new Regex(@"[\s \(\)()\[\]<>]", RegexOptions.Compiled));
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.Replace(oldSrcUnit, "");
343+
//if (unitRegex == null) {
344+
// unitRegex = new Regex(@"[\s \(\)()\[\]<>]", RegexOptions.Compiled);
345+
//}
346+
oldSrcUnit = unitRegex.Value.Replace(oldSrcUnit, "");
347347
if (oldSrcUnit == oldTarUnit) { return src; }
348348

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

0 commit comments

Comments
 (0)