Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions Sources/TOMLDecoder/Parsing/TOMLDocument.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Foundation

struct TOMLDocument: Equatable, @unchecked Sendable {
final class DocumentStorage: @unchecked Sendable, Equatable {
let tables: [InternalTOMLTable]
let arrays: [InternalTOMLArray]
let keyTables: [KeyTablePair]
let keyArrays: [KeyArrayPair]
let keyValues: [KeyValuePair]

let source: String

init(
Expand All @@ -25,6 +24,44 @@
self.keyValues = keyValues
}

static func == (lhs: DocumentStorage, rhs: DocumentStorage) -> Bool {
lhs.source == rhs.source &&
lhs.tables == rhs.tables &&
lhs.arrays == rhs.arrays &&
lhs.keyTables == rhs.keyTables &&
lhs.keyArrays == rhs.keyArrays &&
lhs.keyValues == rhs.keyValues
}
}

struct TOMLDocument: Equatable, @unchecked Sendable {
fileprivate let storage: DocumentStorage

var tables: [InternalTOMLTable] { storage.tables }
var arrays: [InternalTOMLArray] { storage.arrays }
var keyTables: [KeyTablePair] { storage.keyTables }
var keyArrays: [KeyArrayPair] { storage.keyArrays }
var keyValues: [KeyValuePair] { storage.keyValues }
var source: String { storage.source }

init(
source: String,
tables: [InternalTOMLTable],
arrays: [InternalTOMLArray],
keyTables: [KeyTablePair],
keyArrays: [KeyArrayPair],
keyValues: [KeyValuePair]
) {
self.storage = DocumentStorage(

Check warning on line 55 in Sources/TOMLDecoder/Parsing/TOMLDocument.swift

View workflow job for this annotation

GitHub Actions / Swift

Insert/remove explicit self where applicable. (redundantSelf)

Check warning on line 55 in Sources/TOMLDecoder/Parsing/TOMLDocument.swift

View workflow job for this annotation

GitHub Actions / Swift

Insert/remove explicit self where applicable. (redundantSelf)

Check warning on line 55 in Sources/TOMLDecoder/Parsing/TOMLDocument.swift

View workflow job for this annotation

GitHub Actions / Swift

Insert/remove explicit self where applicable. (redundantSelf)

Check warning on line 55 in Sources/TOMLDecoder/Parsing/TOMLDocument.swift

View workflow job for this annotation

GitHub Actions / Swift

Insert/remove explicit self where applicable. (redundantSelf)

Check warning on line 55 in Sources/TOMLDecoder/Parsing/TOMLDocument.swift

View workflow job for this annotation

GitHub Actions / Swift

Insert/remove explicit self where applicable. (redundantSelf)

Check warning on line 55 in Sources/TOMLDecoder/Parsing/TOMLDocument.swift

View workflow job for this annotation

GitHub Actions / Swift

Insert/remove explicit self where applicable. (redundantSelf)
source: source,
tables: tables,
arrays: arrays,
keyTables: keyTables,
keyArrays: keyArrays,
keyValues: keyValues
)
}

init(source: String, keyTransform: (@Sendable (String) -> String)?) throws(TOMLError) {
var hasContinousStorage = false
var parser = Parser(keyTransform: keyTransform)
Expand Down
Loading