Skip to content

Commit 5b5b714

Browse files
committed
compile the regex
1 parent 9be407f commit 5b5b714

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

StabilityMatrix.Core/Python/PipInstallArgs.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace StabilityMatrix.Core.Python;
99

1010
[SuppressMessage("ReSharper", "StringLiteralTypo")]
11-
public record PipInstallArgs : ProcessArgsBuilder
11+
public partial record PipInstallArgs : ProcessArgsBuilder
1212
{
1313
public PipInstallArgs(params Argument[] arguments)
1414
: base(arguments) { }
@@ -70,7 +70,7 @@ private static string NormalizePackageSpecifier(string specifier)
7070

7171
// Regex to match common version constraint patterns with spaces
7272
// Matches: package >= 1.0.0, package <= 1.0.0, package == 1.0.0, etc.
73-
var versionConstraintPattern = new Regex(@"^([a-zA-Z0-9\-_.]+)\s*(>=|<=|==|>|<|!=|~=)\s*(.+)$");
73+
var versionConstraintPattern = PackageSpecifierRegex();
7474

7575
var match = versionConstraintPattern.Match(specifier);
7676
if (match.Success)
@@ -136,4 +136,7 @@ public override string ToString()
136136
{
137137
return base.ToString();
138138
}
139+
140+
[GeneratedRegex(@"^([a-zA-Z0-9\-_.]+)\s*(>=|<=|==|>|<|!=|~=)\s*(.+)$")]
141+
private static partial Regex PackageSpecifierRegex();
139142
}

0 commit comments

Comments
 (0)