Skip to content

Commit

Permalink
Keep the underlying storage capacity when clearing the FlatBufferBuil…
Browse files Browse the repository at this point in the history
…der. Gives a significant performance boost for serialisation of many small messages. (google#7250)
  • Loading branch information
hassila committed Apr 16, 2022
1 parent a10b0e5 commit e37156a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions swift/Sources/FlatBuffers/FlatBufferBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit e37156a

Please sign in to comment.