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

Method WriteData

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

Source from the content-addressed store, hash-verified

510}
511
512func (s uint8ArraySerializer) WriteData(ctx *WriteContext, value reflect.Value) {
513 buf := ctx.Buffer()
514 length := value.Len()
515 buf.WriteLength(length)
516 if length > 0 {
517 if value.CanAddr() {
518 // Fast path: direct memory copy - uint8 is 1 byte
519 ptr := value.Addr().UnsafePointer()
520 buf.WriteBinary(unsafe.Slice((*byte)(ptr), length))
521 } else {
522 // Slow path for non-addressable arrays
523 for i := 0; i < length; i++ {
524 buf.WriteByte(byte(value.Index(i).Uint()))
525 }
526 }
527 }
528}
529
530func (s uint8ArraySerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) {
531 writeArrayRefAndType(ctx, refMode, writeType, value, BINARY)

Callers 1

WriteMethod · 0.95

Calls 6

LenMethod · 0.80
SliceMethod · 0.80
BufferMethod · 0.45
WriteLengthMethod · 0.45
WriteBinaryMethod · 0.45
WriteByteMethod · 0.45

Tested by

no test coverage detected