Keep the underlying storage capacity when clearing the FlatBufferBuilder. Gives a significant performance boost for serialisation of many small messages. (#7250)

This commit is contained in:
Joakim Hassila
2022-04-16 11:25:44 +02:00
committed by GitHub
parent a10b0e5464
commit e37156a305

View File

@@ -127,8 +127,8 @@ public struct FlatBufferBuilder {
mutating public func clear() { mutating public func clear() {
_minAlignment = 0 _minAlignment = 0
isNested = false isNested = false
stringOffsetMap = [:] stringOffsetMap.removeAll(keepingCapacity: true)
_vtables = [] _vtables.removeAll(keepingCapacity: true)
_vtableStorage.clear() _vtableStorage.clear()
_bb.clear() _bb.clear()
} }