[Swift] Moves capacity outside of Storage (#8650)

- Cleans up capacity usage within the lib and moves it outside of the Storage

-  Use overflow operators
This commit is contained in:
mustiikhalil
2025-07-29 23:21:20 +02:00
committed by GitHub
parent f32a7dcbd2
commit 575d616e60
13 changed files with 121 additions and 110 deletions

View File

@@ -143,7 +143,7 @@ public struct FlexBuffersWriter {
{
let vec = createVector(
start: start,
count: stack.count - start,
count: stack.count &- start,
step: 1,
typed: typed,
fixed: fixed,
@@ -211,7 +211,7 @@ public struct FlexBuffersWriter {
typed: true,
fixed: false)
let vec = createVector(
start: start + 1,
start: start &+ 1,
count: len,
step: 2,
typed: false,
@@ -598,7 +598,7 @@ public struct FlexBuffersWriter {
var sloc: UInt = numericCast(writerIndex)
key.withCString {
_bb.writeBytes($0, len: len + 1)
_bb.writeBytes($0, len: len &+ 1)
}
if flags > .shareKeys {
@@ -705,7 +705,7 @@ public struct FlexBuffersWriter {
/// If this vector is part of a map, we will pre-fix an offset to the keys
/// to this vector.
bitWidth = max(bitWidth, keys!.elementWidth(size: writerIndex, index: 0))
prefixElements += 2
prefixElements = prefixElements &+ 2
}
var vectorType: FlexBufferType = .key