bulk code format fix (#8707)

This commit is contained in:
Derek Bailey
2025-09-23 21:50:27 -07:00
committed by GitHub
parent 0e047869da
commit caf3b494db
559 changed files with 38871 additions and 31276 deletions

View File

@@ -18,7 +18,10 @@ import Foundation
@usableFromInline
enum BitWidth: UInt64, CaseIterable {
case w8 = 0, w16 = 1, w32 = 2, w64 = 3
case w8 = 0
case w16 = 1
case w32 = 2
case w64 = 3
}
extension BitWidth: Comparable {

View File

@@ -14,11 +14,12 @@
* limitations under the License.
*/
#if canImport(Common)
import Common
#endif
import Foundation
#if canImport(Common)
import Common
#endif
extension UInt64 {
static let one: UInt64 = 1
}
@@ -55,4 +56,3 @@ extension Optional {
}
}
}

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
#if canImport(Common)
import Common
#endif
import Foundation
#if canImport(Common)
import Common
#endif
public struct Value: Equatable {
@usableFromInline
@@ -110,9 +110,11 @@ extension Value {
return bitWidth
} else {
for byteWidth in stride(from: 1, to: MemoryLayout<UInt64>.size, by: 2) {
let _offsetLoc: UInt64 = numericCast(numericCast(size) &+ padding(
bufSize: numericCast(size),
elementSize: numericCast(byteWidth)))
let _offsetLoc: UInt64 = numericCast(
numericCast(size)
&+ padding(
bufSize: numericCast(size),
elementSize: numericCast(byteWidth)))
let offsetLoc = _offsetLoc &+ (index &* numericCast(byteWidth))
let offset = offsetLoc &- u

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
#if canImport(Common)
import Common
#endif
import Foundation
#if canImport(Common)
import Common
#endif
@inline(__always)
internal func isInline(_ t: FlexBufferType) -> Bool {
return t <= .float || t == .bool
@@ -73,17 +73,26 @@ func getScalarType<T>(type: T.Type) -> FlexBufferType where T: Scalar {
@inline(__always)
func toTypedVector(type: FlexBufferType, length: UInt64) -> FlexBufferType {
let type: UInt64 = switch length {
case 0: type.rawValue &- FlexBufferType.int.rawValue &+ FlexBufferType
.vectorInt.rawValue
case 2: type.rawValue &- FlexBufferType.int.rawValue &+ FlexBufferType
.vectorInt2.rawValue
case 3: type.rawValue &- FlexBufferType.int.rawValue &+ FlexBufferType
.vectorInt3.rawValue
case 4: type.rawValue &- FlexBufferType.int.rawValue &+ FlexBufferType
.vectorInt4.rawValue
default: 0
}
let type: UInt64 =
switch length {
case 0:
type.rawValue &- FlexBufferType.int.rawValue
&+ FlexBufferType
.vectorInt.rawValue
case 2:
type.rawValue &- FlexBufferType.int.rawValue
&+ FlexBufferType
.vectorInt2.rawValue
case 3:
type.rawValue &- FlexBufferType.int.rawValue
&+ FlexBufferType
.vectorInt3.rawValue
case 4:
type.rawValue &- FlexBufferType.int.rawValue
&+ FlexBufferType
.vectorInt4.rawValue
default: 0
}
return FlexBufferType(rawValue: type) ?? .null
}
@@ -100,7 +109,8 @@ func isTypedVectorType(type: FlexBufferType) -> Bool {
@inline(__always)
func toTypedVectorElementType(type: FlexBufferType) -> FlexBufferType? {
return FlexBufferType(
rawValue: type.rawValue &- FlexBufferType.vectorInt
rawValue: type.rawValue
&- FlexBufferType.vectorInt
.rawValue &+ FlexBufferType.int.rawValue)
}
@@ -115,12 +125,16 @@ func toFixedTypedVectorElementType(type: FlexBufferType)
{
assert(isFixedTypedVectorType(type: type))
let fixedType: UInt64 = numericCast(
type.rawValue &- FlexBufferType.vectorInt2
type.rawValue
&- FlexBufferType.vectorInt2
.rawValue)
let len: Int = numericCast(fixedType.dividedReportingOverflow(by: 3).partialValue &+ 2)
return (
FlexBufferType(rawValue: (fixedType.quotientAndRemainder(dividingBy: 3).remainder) &+ FlexBufferType.int.rawValue),
len)
FlexBufferType(
rawValue: (fixedType.quotientAndRemainder(dividingBy: 3).remainder)
&+ FlexBufferType.int.rawValue),
len
)
}
// MARK: - Reader functions
@@ -128,8 +142,8 @@ func toFixedTypedVectorElementType(type: FlexBufferType)
@inline(__always)
func binarySearch(
vector: TypedVector,
target: String) -> Int?
{
target: String
) -> Int? {
var left = 0
var right = vector.count
@@ -149,14 +163,17 @@ func binarySearch(
@inline(__always)
func readIndirect(buffer: ByteBuffer, offset: Int, _ byteWidth: UInt8) -> Int {
return offset &- numericCast(buffer.readUInt64(
offset: offset,
byteWidth: byteWidth))
return offset
&- numericCast(
buffer.readUInt64(
offset: offset,
byteWidth: byteWidth))
}
@inline(__always)
func getCount(buffer: ByteBuffer, offset: Int, byteWidth: UInt8) -> Int {
Int(buffer.readUInt64(
offset: offset &- numericCast(byteWidth),
byteWidth: byteWidth))
Int(
buffer.readUInt64(
offset: offset &- numericCast(byteWidth),
byteWidth: byteWidth))
}