From e1ecb35531b2fe0a488ef8e7a5aeaf28c26d6709 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 18 Dec 2019 13:14:56 -0500 Subject: [PATCH] remove unused code --- .../MVMCore/Models/Model/ModelRegistry.swift | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift index b811646..ee741bf 100644 --- a/MVMCore/MVMCore/Models/Model/ModelRegistry.swift +++ b/MVMCore/MVMCore/Models/Model/ModelRegistry.swift @@ -80,27 +80,20 @@ extension KeyedDecodingContainer where Key: CodingKey { var models = [Model]() var container = try nestedUnkeyedContainer(forKey: codingKey) var containerCopy = container - - var i = 0 - let count = container.count ?? 0 - while !container.isAtEnd { - if i < count { - let nestedContainer = try container.nestedContainer(keyedBy: C.self) - if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) { - //get the type - guard let type = ModelRegistry.types[identifier] else { - throw ModelRegistry.Error.decoderErrorModelNotMapped - } - //now get the decoder to use for the type - let decoder = try containerCopy.superDecoder() - let model = try type.init(from: decoder) - models.append(model) + let nestedContainer = try container.nestedContainer(keyedBy: C.self) + if let identifier = try nestedContainer.decodeIfPresent(String.self, forKey: typeCodingKey) { + //get the type + guard let type = ModelRegistry.types[identifier] else { + throw ModelRegistry.Error.decoderErrorModelNotMapped } - i+=1 + //now get the decoder to use for the type + let decoder = try containerCopy.superDecoder() + let model = try type.init(from: decoder) + models.append(model) } } - return models.count > 0 ? models : nil + return models } /// Decodes an array of registered model based on the identifiers.