mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-03 23:49:38 +00:00 
			
		
		
		
	Can now change graph into a struct
This commit is contained in:
		@ -5,7 +5,7 @@
 | 
			
		||||
 | 
			
		||||
import Foundation
 | 
			
		||||
 | 
			
		||||
public class ApkPackageGraph {
 | 
			
		||||
public struct ApkPackageGraph: ~Copyable {
 | 
			
		||||
  private var _nodes = [ApkPackageGraphNode]()
 | 
			
		||||
 | 
			
		||||
  public var nodes: [ApkPackageGraphNode] { self._nodes }
 | 
			
		||||
@ -14,7 +14,7 @@ public class ApkPackageGraph {
 | 
			
		||||
 | 
			
		||||
  public init() {}
 | 
			
		||||
 | 
			
		||||
  public func buildGraphNode(index pkgIndex: ApkIndex, providers: ApkIndexProviderCache) {
 | 
			
		||||
  public mutating func buildGraphNode(index pkgIndex: ApkIndex, providers: ApkIndexProviderCache) {
 | 
			
		||||
    for (packageID, package) in pkgIndex.packages.enumerated() {
 | 
			
		||||
      let children: [ApkPackageGraphNode.ChildRef] = package.dependencies.compactMap { dependency in
 | 
			
		||||
        guard let providerID = providers.resolve(index: pkgIndex, requirement: dependency.requirement) else {
 | 
			
		||||
@ -27,7 +27,7 @@ public class ApkPackageGraph {
 | 
			
		||||
        }
 | 
			
		||||
        return .init(constraint: .installIf, packageID: prvID, versionSpec: installIf.requirement.versionSpec)
 | 
			
		||||
      } */
 | 
			
		||||
      self._nodes.append(.init(self,
 | 
			
		||||
      self._nodes.append(.init(
 | 
			
		||||
        id: packageID,
 | 
			
		||||
        children: children
 | 
			
		||||
      ))
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ public class ApkPackageGraphNode {
 | 
			
		||||
  @inlinable public var isShallow: Bool { self.parentIDs.isEmpty }
 | 
			
		||||
  @inlinable public var isDeep: Bool { self.children.isEmpty }
 | 
			
		||||
 | 
			
		||||
  internal init(_ graph: ApkPackageGraph, id: Int, children: [ChildRef]) {
 | 
			
		||||
  internal init(id: Int, children: [ChildRef]) {
 | 
			
		||||
    self.packageID = id
 | 
			
		||||
    self.children = children
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ struct DpkGraphCommand: AsyncParsableCommand {
 | 
			
		||||
 | 
			
		||||
      timerStart = DispatchTime.now()
 | 
			
		||||
      let providerCache = ApkIndexProviderCache(index: pkgIndex)
 | 
			
		||||
      let graph = ApkPackageGraph()
 | 
			
		||||
      var graph = ApkPackageGraph()
 | 
			
		||||
      graph.buildGraphNode(index: pkgIndex, providers: providerCache)
 | 
			
		||||
      print("Graph build took \(timerStart.distance(to: .now()).seconds) seconds")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user