Skip to content

Commit a83b148

Browse files
committed
replaced tuples to framework
1 parent cefbf3f commit a83b148

File tree

8 files changed

+1185
-1530
lines changed

8 files changed

+1185
-1530
lines changed

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ let package = Package(
1212
targets: ["ScaleCodec"]),
1313
],
1414
dependencies: [
15-
// Dependencies declare other packages that this package depends on.
15+
.package(url: "https://github.com/tesseract-one/Tuples.swift.git", .branch("main"))
1616
],
1717
targets: [
1818
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
1919
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
2020
.target(
2121
name: "ScaleCodec",
22-
dependencies: ["DoubleWidth"]),
22+
dependencies: [
23+
.product(name: "Tuples", package: "Tuples.swift"),
24+
"DoubleWidth"
25+
]),
2326
.target(
2427
name: "DoubleWidth",
2528
dependencies: []),

Sources/ScaleCodec/Custom.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ extension Encoder {
3939
}
4040
}
4141

42-
public func encode<T>(_ value: T, _ custom: CustomEncoderFactory<T, DataEncoder>,
43-
reservedCapacity count: Int = 4096) throws -> Data
44-
{
42+
public func encode<T>(
43+
_ value: T, _ custom: CustomEncoderFactory<T, DataEncoder>,
44+
reservedCapacity count: Int = SCALE_CODEC_DEFAULT_ENCODER_CAPACITY
45+
) throws -> Data {
4546
var _encoder = encoder(reservedCapacity: count)
4647
try _encoder.encode(value, custom)
4748
return _encoder.output

Sources/ScaleCodec/Scale.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@ import Foundation
99

1010
public typealias Codable = Encodable & Decodable
1111

12+
public var SCALE_CODEC_DEFAULT_ENCODER_CAPACITY: Int = 4096 // 4kb
13+
1214
@inlinable
13-
public func encoder(reservedCapacity count: Int = 4096) -> DataEncoder {
15+
public func encoder(reservedCapacity count: Int = SCALE_CODEC_DEFAULT_ENCODER_CAPACITY) -> DataEncoder {
1416
DataEncoder(reservedCapacity: count)
1517
}
1618

1719
@inlinable
1820
public func decoder(from data: Data) -> DataDecoder { DataDecoder(data: data) }
1921

2022
@inlinable
21-
public func encode<T: Encodable>(_ value: T, reservedCapacity count: Int = 4096) throws -> Data {
23+
public func encode<T: Encodable>(
24+
_ value: T,
25+
reservedCapacity count: Int = SCALE_CODEC_DEFAULT_ENCODER_CAPACITY
26+
) throws -> Data {
2227
var _encoder = encoder(reservedCapacity: count)
2328
try _encoder.encode(value)
2429
return _encoder.output

Sources/ScaleCodec/Tuple.swift

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)