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() {
_minAlignment = 0
isNested = false
stringOffsetMap = [:]
_vtables = []
stringOffsetMap.removeAll(keepingCapacity: true)
_vtables.removeAll(keepingCapacity: true)
_vtableStorage.clear()
_bb.clear()
}