From 3ccbfb36afcbd63ad77e8c3d7c211f246d4d3e16 Mon Sep 17 00:00:00 2001 From: James Bean Date: Mon, 30 Sep 2019 13:52:39 -0400 Subject: [PATCH 1/2] Transform precondition to where clause in switch statement --- Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift index b0284f9a..2e77d663 100644 --- a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift +++ b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift @@ -101,8 +101,7 @@ class XMLDecoderImplementation: Decoder { attributes: KeyedStorage() )) )) - case let containsEmpty as SingleKeyedBox: - precondition(containsEmpty.element is NullBox) + case let containsEmpty as SingleKeyedBox where containsEmpty.element is NullBox: return KeyedDecodingContainer(XMLKeyedDecodingContainer( referencing: self, wrapping: SharedBox(KeyedBox( elements: KeyedStorage([("value", StringBox(""))]), attributes: KeyedStorage() From 800a26a367a8eb045159250bc61571220d925707 Mon Sep 17 00:00:00 2001 From: James Bean Date: Mon, 30 Sep 2019 13:53:58 -0400 Subject: [PATCH 2/2] Remove print statements --- Sources/XMLCoder/Decoder/XMLDecoder.swift | 2 -- Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift | 3 --- Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift | 3 --- 3 files changed, 8 deletions(-) diff --git a/Sources/XMLCoder/Decoder/XMLDecoder.swift b/Sources/XMLCoder/Decoder/XMLDecoder.swift index 81c590ff..024b9935 100644 --- a/Sources/XMLCoder/Decoder/XMLDecoder.swift +++ b/Sources/XMLCoder/Decoder/XMLDecoder.swift @@ -349,8 +349,6 @@ open class XMLDecoder { trimValueWhitespaces: trimValueWhitespaces ) - print("decoder.decode(\(type), from: \(data), top level: \(topLevel)") - let decoder = XMLDecoderImplementation( referencing: topLevel, options: options, diff --git a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift index 2e77d663..a88d3189 100644 --- a/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift +++ b/Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift @@ -443,10 +443,7 @@ extension XMLDecoderImplementation { storage.popContainer() } - print("type: \(type), box: \(box)") - do { - print("try decoding in init") decoded = try type.init(from: self) } catch { guard case DecodingError.valueNotFound = error, diff --git a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift index 9d937a0d..0c486114 100644 --- a/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift +++ b/Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift @@ -324,14 +324,11 @@ extension XMLKeyedDecodingContainer { box = anyBox } - print(box) - let value: T? if !(type is AnySequence.Type), let unkeyedBox = box as? UnkeyedBox, let first = unkeyedBox.first { // Handle case where we have held onto a `SingleKeyedBox` if let singleKeyed = first as? SingleKeyedBox { - print("single keyed here?: \(singleKeyed.element)") if singleKeyed.element.isNull { value = try decoder.unbox(singleKeyed) } else {