MCPcopy Create free account
hub / github.com/apache/fory / WriteData

Method WriteData

go/fory/array_primitive.go:378–395  ·  view source on GitHub ↗
(ctx *WriteContext, value reflect.Value)

Source from the content-addressed store, hash-verified

376}
377
378func (s float32ArraySerializer) WriteData(ctx *WriteContext, value reflect.Value) {
379 buf := ctx.Buffer()
380 length := value.Len()
381 size := length * 4
382 buf.WriteLength(size)
383 if length > 0 {
384 if value.CanAddr() && isLittleEndian {
385 // Fast path: direct memory copy - little-endian only
386 ptr := value.Addr().UnsafePointer()
387 buf.WriteBinary(unsafe.Slice((*byte)(ptr), size))
388 } else {
389 // Slow path for non-addressable arrays or big-endian
390 for i := 0; i < length; i++ {
391 buf.WriteFloat32(float32(value.Index(i).Float()))
392 }
393 }
394 }
395}
396
397func (s float32ArraySerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) {
398 writeArrayRefAndType(ctx, refMode, writeType, value, FLOAT32_ARRAY)

Callers 1

WriteMethod · 0.95

Calls 7

LenMethod · 0.80
SliceMethod · 0.80
float32Function · 0.50
BufferMethod · 0.45
WriteLengthMethod · 0.45
WriteBinaryMethod · 0.45
WriteFloat32Method · 0.45

Tested by

no test coverage detected