Skip to content

Commit

Permalink
Return a List(Of String) instead of just a String that we split...
Browse files Browse the repository at this point in the history
later when getting the manifest paths. This should improve performance and resource usage.
  • Loading branch information
DrewNaylor committed Oct 5, 2020
1 parent c909399 commit e1e81e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions guinget/MainWindow.vb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Public Class aaformMainWindow
aaformMainWindow.Update()

' Now we populate the Manifest column with each manifest.
Dim ManifestPaths() As String = PackageListTools.GetManifests.TrimEnd.Split(CType("?", Char()))
Dim ManifestPaths As List(Of String) = PackageListTools.GetManifests

' Set progress bar maximum and step count.
aaformMainWindow.toolstripprogressbarLoadingPackages.Maximum = ManifestPaths.Count - 1
Expand All @@ -98,7 +98,7 @@ Public Class aaformMainWindow
' Go through everything in the manifest paths array until it's out if
' we don't want to load from a database.
If My.Settings.LoadFromSqliteDb = False Then
For i As Integer = 0 To ManifestPaths.Count - 2
For i As Integer = 0 To ManifestPaths.Count - 1

' Read the file into the manifest column and make a new row with it.
aaformMainWindow.datagridviewPackageList.Rows.Add("Do nothing", "Unknown", "Loading...", "Loading...", "Loading...", "Unknown", "Loading...", ManifestPaths(i))
Expand Down Expand Up @@ -166,7 +166,7 @@ Public Class aaformMainWindow
' These have to be grabbed now or else updating the manifests
' will crash when the path doesn't exist.
ElseIf My.Settings.LoadFromSqliteDb = True Then
PackageListTools.FallbackPathList = PackageListTools.GetManifests.TrimEnd.Split(CType("?", Char()))
PackageListTools.FallbackPathList = PackageListTools.GetManifests

' Now we need to load the manifests and the descriptions.
For Each PackageRow As DataGridViewRow In aaformMainWindow.datagridviewPackageList.Rows
Expand Down
8 changes: 4 additions & 4 deletions libguinget/PackageListTools.vb
Original file line number Diff line number Diff line change
Expand Up @@ -438,22 +438,22 @@ Public Class PackageListTools

End Function

Public Shared Function GetManifests() As String
Public Shared Function GetManifests() As List(Of String)
' Get and return each manifest in the manifests folder.
' This should only be used after ensuring that there's
' stuff in this folder, or it'll crash.
Dim ManifestAppDataFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\winget-frontends\source\winget-pkgs\pkglist\manifests"

' Define a variable so we can store the manifest paths.
Dim ManifestPath As String = String.Empty
Dim ManifestPath As List(Of String) = New List(Of String)

' Take the Id string for each package file and append it to the
' package list array variable.
For Each PackageManifest As String In My.Computer.FileSystem.GetFiles(ManifestAppDataFolder, FileIO.SearchOption.SearchAllSubDirectories, "*.yaml")

' Append the current package manifest's path to the ManifestPath string.
' Using a question mark since it's not allowed in path names.
ManifestPath = ManifestPath & PackageManifest & "?"
ManifestPath.Add(PackageManifest)
Next

Return ManifestPath
Expand All @@ -464,7 +464,7 @@ Public Class PackageListTools
' If the folder used here doesn't exist, applications using this
' library will crash, so it has to be set by the calling application before
' being used.
Public Shared FallbackPathList() As String
Public Shared FallbackPathList As List(Of String)

Public Shared Async Function FindManifestByVersionAndId(ManifestId As String, ManifestVersion As String) As Task(Of String)
' We'll look through the manifests in the cache, and if there's a version number match,
Expand Down

0 comments on commit e1e81e4

Please sign in to comment.