Repository: google/flatbuffers
File: swift/Sources/FlatBuffers/FlatBufferBuilder.swift (Swift)

Code before:
  /// ```
  ///
  /// - Parameter elements: Elements to be written into the buffer
  /// - Parameter size: Count of elements
  /// - returns: ``Offset`` of the vector
  @inline(__always)
  mutating public func createVector<T: Scalar>(
    _ elements: [T],
    size: Int) -> Offset
  {
    let size = size
    startVector(size, elementSize: MemoryLayout<T>.size)
    _bb.push(elements: elements)
    return endVector(len: size)
  }

  @inline(__always) @inlinable
  mutating public func createVector<T: FixedWidthInteger>(ints: [T]) -> Offset {
    startVector(ints.count, elementSize: MemoryLayout<T>.size)
    var littleEndianInts = ints.map { $0.littleEndian }
    littleEndianInts.withUnsafeBytes { ptr in
      _bb.push(bytes: ptr)
    }
    return endVector(len: ints.count)
  }

  #if swift(>=5.0) && !os(WASI)
  @inline(__always)
  mutating public func createVector(bytes: ContiguousBytes) -> Offset {
    let size = bytes.withUnsafeBytes { ptr in ptr.count }
    startVector(size, elementSize: MemoryLayout<UInt8>.size)
    _bb.push(bytes: bytes)
    return endVector(len: size)
  }
  #endif

  /// Creates a vector of type ``Enum`` into the ``ByteBuffer``
  ///
  /// ``createVector(_:)-9h189`` writes a vector of type ``Enum`` into
  /// ``ByteBuffer``. This is a convenient method instead of calling,
  /// ``startVector(_:elementSize:)`` and then ``endVector(len:)``
  /// ```swift
  /// let vectorOffset = builder.
  ///   createVector([.swift, .cpp])
  /// ```
  ///
  /// The underlying implementation simply calls ``createVector(_:size:)-7cx6z``
  ///
  /// - Parameter elements: elements to be written into the buffer
  /// - returns: ``Offset`` of the vector
  @inline(__always)

Review comment (suggestion):
This function isn't needed, please migrate the original [push scalar elements](https://github.com/google/flatbuffers/blob/7d6d99c6befa635780a4e944d37ebfd58e68a108/swift/Sources/FlatBuffers/ByteBuffer.swift#L230C8-L230C8) instead to the new way of pushing into the buffer as mentioned in discord


Code after:
  /// ```
  ///
  /// - Parameter elements: Elements to be written into the buffer
  /// - Parameter size: Count of elements
  /// - returns: ``Offset`` of the vector
  @inline(__always)
  mutating public func createVector<T: Scalar>(
    _ elements: [T],
    size: Int) -> Offset
  {
    let size = size
    startVector(size, elementSize: MemoryLayout<T>.size)
    _bb.push(elements: elements)
    return endVector(len: size)
  }

  #if swift(>=5.0) && !os(WASI)
  @inline(__always)
  /// Creates a vector of bytes in the buffer.
  ///
  /// Allows creating a vector from `Data` without copying to a `[UInt8]`
  ///
  /// - Parameter bytes: bytes to be written into the buffer
  /// - Returns: ``Offset`` of the vector
  mutating public func createVector(bytes: ContiguousBytes) -> Offset {
    let size = bytes.withUnsafeBytes { ptr in ptr.count }
    startVector(size, elementSize: MemoryLayout<UInt8>.size)
    _bb.push(bytes: bytes)
    return endVector(len: size)
  }
  #endif

  /// Creates a vector of type ``Enum`` into the ``ByteBuffer``
  ///
  /// ``createVector(_:)-9h189`` writes a vector of type ``Enum`` into
  /// ``ByteBuffer``. This is a convenient method instead of calling,
  /// ``startVector(_:elementSize:)`` and then ``endVector(len:)``
  /// ```swift
  /// let vectorOffset = builder.
  ///   createVector([.swift, .cpp])
  /// ```
  ///
  /// The underlying implementation simply calls ``createVector(_:size:)-7cx6z``
  ///
  /// - Parameter elements: elements to be written into the buffer
  /// - returns: ``Offset`` of the vector
  @inline(__always)
  mutating public func createVector<T: Enum>(_ elements: [T]) -> Offset {
    createVector(elements, size: elements.count)
  }