diff --git a/Sources/apk/Graph/ApkPackageGraph.swift b/Sources/apk/Graph/ApkPackageGraph.swift index 4d7403c..134cffc 100644 --- a/Sources/apk/Graph/ApkPackageGraph.swift +++ b/Sources/apk/Graph/ApkPackageGraph.swift @@ -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 )) diff --git a/Sources/apk/Graph/ApkPackageGraphNode.swift b/Sources/apk/Graph/ApkPackageGraphNode.swift index cb8c3ca..bdbaf06 100644 --- a/Sources/apk/Graph/ApkPackageGraphNode.swift +++ b/Sources/apk/Graph/ApkPackageGraphNode.swift @@ -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 } diff --git a/Sources/dpk-cli/Subcommands/DpkGraphCommand.swift b/Sources/dpk-cli/Subcommands/DpkGraphCommand.swift index fec57e5..d0abf59 100644 --- a/Sources/dpk-cli/Subcommands/DpkGraphCommand.swift +++ b/Sources/dpk-cli/Subcommands/DpkGraphCommand.swift @@ -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")