File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -145,13 +145,11 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
145
145
146
146
@inline ( __always)
147
147
func unwrap< T: Decodable > ( ) throws -> T {
148
- let value = representation
149
-
150
148
typealias Primitive = DynamicCodable
151
149
152
150
switch T . self {
153
151
// Return DynamicCodable as is if it is being decoded
154
- case is DynamicCodable . Type : return unsafeBitCast ( value , to: T . self)
152
+ case is DynamicCodable . Type : return unsafeBitCast ( representation , to: T . self)
155
153
// Primitive Types fast-path
156
154
case is Primitive . Float32 . Type : return unsafeBitCast ( try unwrapFloatingPoint ( ) as Primitive . Float32 , to: T . self)
157
155
case is Primitive . Float64 . Type : return unsafeBitCast ( try unwrapFloatingPoint ( ) as Primitive . Float64 , to: T . self)
@@ -170,12 +168,17 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
170
168
is Primitive . Nil . Type ,
171
169
is Primitive . Bool . Type ,
172
170
is Primitive . String . Type ,
173
- is Primitive . Empty . Type : return try value . unwrap { throw createTypeMismatchError ( type : T . self ) }
171
+ is Primitive . Empty . Type : return try unwrapPrimitive ( )
174
172
// Decodable Types
175
173
default : return try T ( from: self )
176
174
}
177
175
}
178
176
177
+ @inline ( __always)
178
+ private func unwrapPrimitive< T> ( ) throws -> T {
179
+ try representation. unwrap { throw createTypeMismatchError ( type: T . self) }
180
+ }
181
+
179
182
@inline ( __always)
180
183
private func unwrapFloatingPoint< T: BinaryFloatingPoint > ( ) throws -> T {
181
184
@inline ( __always)
You can’t perform that action at this time.
0 commit comments