From c7e395922e73acce4d0eb9c77a79c755e99663c6 Mon Sep 17 00:00:00 2001 From: Adora Lynch Date: Wed, 27 Nov 2024 00:05:55 -0500 Subject: [PATCH] no message --- Sources/Yams/AliasDereferencingStrategy.swift | 11 ++++++----- Sources/Yams/Decoder.swift | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/Yams/AliasDereferencingStrategy.swift b/Sources/Yams/AliasDereferencingStrategy.swift index 2ce8d1ec..19e67689 100644 --- a/Sources/Yams/AliasDereferencingStrategy.swift +++ b/Sources/Yams/AliasDereferencingStrategy.swift @@ -18,12 +18,13 @@ /// distinct anchors in the YAML document). In some scenarios this may significantly reduce the memory footprint of /// the decoded type. public protocol AliasDereferencingStrategy: AnyObject { - + typealias Value = (any Decodable) /// get and set cached references, keyed bo an Anchor - subscript(_ key: Anchor) -> Any? { get set } + subscript(_ key: Anchor) -> Value? { get set } } -/// A AliasDereferencingStrategy which caches all values (even value-type values) in a Dictionary, keyed by their Anchor. +/// A AliasDereferencingStrategy which caches all values (even value-type values) in a Dictionary, +/// keyed by their Anchor. /// For reference types, this strategy achieves reference coalescing /// For value types, this strategy achieves short-cutting the decoding process when dereferencing aliases. /// if the aliased structure is large, this may result in a time savings @@ -31,10 +32,10 @@ public class BasicAliasDereferencingStrategy: AliasDereferencingStrategy { /// Create a new BasicAliasDereferencingStrategy public init() {} - private var map: [Anchor: Any] = .init() + private var map: [Anchor: Value] = .init() /// get and set cached references, keyed bo an Anchor - public subscript(_ key: Anchor) -> Any? { + public subscript(_ key: Anchor) -> Value? { get { map[key] } set { map[key] = newValue } } diff --git a/Sources/Yams/Decoder.swift b/Sources/Yams/Decoder.swift index aeeb528f..270f4412 100644 --- a/Sources/Yams/Decoder.swift +++ b/Sources/Yams/Decoder.swift @@ -380,7 +380,7 @@ extension _Decoder: SingleValueDecodingContainer { return existing } - private func recordAnchor(_ constructed: T) { + private func recordAnchor(_ constructed: T) { guard let anchor = self.node.anchor else { return }