Skip to content

Commit bcaa83e

Browse files
authored
Reserve capacity for basic string (#250)
1 parent 6b272b4 commit bcaa83e

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

Sources/TOMLDecoder/ParserImplementation.Generated.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ func basicString(bytes: borrowing Span<UInt8>, range: Range<Int>, multiline: Boo
13261326
let startIndex = range.lowerBound
13271327
let endIndex = range.upperBound
13281328
var resultCodeUnits: [UTF8.CodeUnit] = []
1329+
resultCodeUnits.reserveCapacity(range.count)
13291330
var consecutiveQuotes = 0
13301331
var index = startIndex
13311332
while true {
@@ -2937,6 +2938,7 @@ func basicString(bytes: UnsafeBufferPointer<UInt8>, range: Range<Int>, multiline
29372938
let startIndex = range.lowerBound
29382939
let endIndex = range.upperBound
29392940
var resultCodeUnits: [UTF8.CodeUnit] = []
2941+
resultCodeUnits.reserveCapacity(range.count)
29402942
var consecutiveQuotes = 0
29412943
var index = startIndex
29422944
while true {

Sources/TOMLDecoder/TOMLTable.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,6 @@ public struct TOMLTable: Sendable, Equatable {
212212
throw TOMLError(.keyNotFoundInTable(key: key, expected: "table"))
213213
}
214214

215-
// @inline(__always)
216-
// func value<T>(forKey key: String, parse: (String.UTF8View.SubSequence) throws(TOMLError) -> T) throws(TOMLError) -> T {
217-
// let pairIndices = source.tables[index].keyValues
218-
// let allPairs = source.keyValues
219-
// for i in pairIndices {
220-
// if allPairs[i].key == key {
221-
// return try parse(allPairs[i].value.text)
222-
// }
223-
// }
224-
225-
// throw TOMLError(.keyNotFoundInTable(key: key, expected: String(describing: T.self)))
226-
// }
227-
228215
@inline(__always)
229216
func token(forKey key: String, expected: String) throws(TOMLError) -> Token {
230217
let pairIndices = source.tables[index].keyValues

Sources/TOMLDecoder/gyb/ParserImplementation.swift.gyb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,7 @@ func basicString(bytes: ${byte_type}, range: Range<Int>, multiline: Bool) throws
13391339
let startIndex = range.lowerBound
13401340
let endIndex = range.upperBound
13411341
var resultCodeUnits: [UTF8.CodeUnit] = []
1342+
resultCodeUnits.reserveCapacity(range.count)
13421343
var consecutiveQuotes = 0
13431344
var index = startIndex
13441345
while true {

0 commit comments

Comments
 (0)