Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing filtered update performance #3233

Merged
merged 3 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/Paket.Core/Common/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,26 @@ type QualifiedPackageName =
let packageName = PackageName packageName
QualifiedPackageName (groupName, packageName)

type PackageMatch(ex:String) =
member val Expression = Regex("^" + ex + "$", RegexOptions.CultureInvariant ||| RegexOptions.IgnoreCase)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this. Personally I would probably prefer:

type PackageMatch(ex:String) =
    let regex = Regex("^" + ex + "$", RegexOptions.CultureInvariant ||| RegexOptions.IgnoreCase) 
    member _.Expression = regex

or even

type PackageMatch =
   { Expression : Regex }
module PackageMatch =
   let ofString ex =
     { Expression = Regex("^" + ex + "$", RegexOptions.CultureInvariant ||| RegexOptions.IgnoreCase) }


// Represents a filter of normalized package names
[<System.Diagnostics.DebuggerDisplay("{ToString()}")>]
type PackageFilter =
| PackageName of PackageName
| PackageFilter of string
| PackageFilter of PackageMatch

member this.Match (packageName : PackageName) =
match this with
| PackageName name -> name = packageName
| PackageFilter f ->
let regex =
Regex("^" + f + "$",
RegexOptions.Compiled
||| RegexOptions.CultureInvariant
||| RegexOptions.IgnoreCase)

regex.IsMatch (packageName.CompareString)
| PackageFilter f -> f.Expression.IsMatch(packageName.CompareString)

static member ofName name = PackageFilter.PackageName name

override this.ToString() =
match this with
| PackageName name -> name.ToString()
| PackageFilter filter -> filter
| PackageFilter filter -> filter.Expression.ToString()


type DomainMessage =
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Installation/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ let UpdatePackage(dependenciesFileName, groupName, packageName : PackageName, ne
let UpdateFilteredPackages(dependenciesFileName, groupName, packageName : string, newVersion, options : UpdaterOptions) =
let dependenciesFile = DependenciesFile.ReadFromFile(dependenciesFileName)

let filter = PackageFilter.PackageFilter(packageName.ToString())
let filter = PackageFilter.PackageFilter(PackageMatch packageName)

let dependenciesFile =
match newVersion with
Expand Down