summaryrefslogtreecommitdiff
path: root/swift/Sources
diff options
context:
space:
mode:
authorJoakim Hassila <jocke@ordo.one>2022-04-16 11:25:44 +0200
committerGitHub <noreply@github.com>2022-04-16 11:25:44 +0200
commite37156a305532819533eeeb05be96a6935edf849 (patch)
treef72545cd1b0a357a66309922e59464d12669ed44 /swift/Sources
parenta10b0e546454ec0704f6d3aad19090bc5ab46ac3 (diff)
downloadflatbuffers-e37156a305532819533eeeb05be96a6935edf849.tar.gz
flatbuffers-e37156a305532819533eeeb05be96a6935edf849.tar.bz2
flatbuffers-e37156a305532819533eeeb05be96a6935edf849.zip
Keep the underlying storage capacity when clearing the FlatBufferBuilder. Gives a significant performance boost for serialisation of many small messages. (#7250)
Diffstat (limited to 'swift/Sources')
-rw-r--r--swift/Sources/FlatBuffers/FlatBufferBuilder.swift4
1 files changed, 2 insertions, 2 deletions
diff --git a/swift/Sources/FlatBuffers/FlatBufferBuilder.swift b/swift/Sources/FlatBuffers/FlatBufferBuilder.swift
index 5ccc7e44..223f7ffa 100644
--- a/swift/Sources/FlatBuffers/FlatBufferBuilder.swift
+++ b/swift/Sources/FlatBuffers/FlatBufferBuilder.swift
@@ -127,8 +127,8 @@ public struct FlatBufferBuilder {
mutating public func clear() {
_minAlignment = 0
isNested = false
- stringOffsetMap = [:]
- _vtables = []
+ stringOffsetMap.removeAll(keepingCapacity: true)
+ _vtables.removeAll(keepingCapacity: true)
_vtableStorage.clear()
_bb.clear()
}