Skip to content

Commit

Permalink
fixes for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ypopovych committed Jun 26, 2023
1 parent 7f4ced3 commit b206861
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions Sources/ScaleCodec/Custom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ extension Encoder {
}
}

public func encode<T>(_ value: T, _ custom: CustomEncoderFactory<T, DataEncoder>, reservedCapacity count: Int = 4096) throws -> Data {
var encoder = encoder(reservedCapacity: count)
try encoder.encode(value, custom)
return encoder.output
public func encode<T>(_ value: T, _ custom: CustomEncoderFactory<T, DataEncoder>,
reservedCapacity count: Int = 4096) throws -> Data
{
var _encoder = encoder(reservedCapacity: count)
try _encoder.encode(value, custom)
return _encoder.output
}

public func decode<T>(_ type: T.Type, _ custom: CustomDecoderFactory<T, DataDecoder>, from data: Data) throws -> T {
return try decode(custom, from: data)
}

public func decode<T>(_ custom: CustomDecoderFactory<T, DataDecoder>, from data: Data) throws -> T {
var decoder = decoder(from: data)
return try decoder.decode(custom)
var _decoder = decoder(from: data)
return try _decoder.decode(custom)
}
10 changes: 5 additions & 5 deletions Sources/ScaleCodec/Scale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public func decoder(from data: Data) -> DataDecoder { DataDecoder(data: data) }

@inlinable
public func encode<T: Encodable>(_ value: T, reservedCapacity count: Int = 4096) throws -> Data {
var encoder = encoder(reservedCapacity: count)
try encoder.encode(value)
return encoder.output
var _encoder = encoder(reservedCapacity: count)
try _encoder.encode(value)
return _encoder.output
}

@inlinable
public func decode<T: Decodable>(from data: Data) throws -> T {
var decoder = decoder(from: data)
return try decoder.decode()
var _decoder = decoder(from: data)
return try _decoder.decode()
}

@inlinable
Expand Down

0 comments on commit b206861

Please sign in to comment.