From 54d71dea4697ba331ab1fe009db13a6c97689f95 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 21 Jun 2023 10:24:15 +0800 Subject: [PATCH] Clean walkedNodes everytime it walks. (#109) --- Sources/Megrez/2_Walker.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Megrez/2_Walker.swift b/Sources/Megrez/2_Walker.swift index d3f771f..a79edac 100644 --- a/Sources/Megrez/2_Walker.swift +++ b/Sources/Megrez/2_Walker.swift @@ -19,10 +19,10 @@ public extension Megrez.Compositor { /// - Returns: 爬軌結果+該過程是否順利執行。 @discardableResult mutating func walk() -> [Megrez.Node] { defer { Self.reinitVertexNetwork() } + walkedNodes.removeAll() sortAndRelax() guard !spans.isEmpty else { return [] } var iterated: Megrez.Node? = Megrez.Node.leadingNode - walkedNodes.removeAll() while let itPrev = iterated?.prev { // 此處必須得是 Copy,讓組字器外部對此的操作影響不到組字器內部的節點。 walkedNodes.insert(itPrev.copy, at: 0)