[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

@@ -117,9 +117,9 @@ func toFixedTypedVectorElementType(type: FlexBufferType)
let fixedType: UInt64 = numericCast(
type.rawValue &- FlexBufferType.vectorInt2
.rawValue)
let len: Int = numericCast((fixedType / 3) + 2)
let len: Int = numericCast(fixedType.dividedReportingOverflow(by: 3).partialValue &+ 2)
return (
FlexBufferType(rawValue: (fixedType % 3) + FlexBufferType.int.rawValue),
FlexBufferType(rawValue: (fixedType.quotientAndRemainder(dividingBy: 3).remainder) &+ FlexBufferType.int.rawValue),
len)
}