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

Method writeDataWithGenerics

go/fory/slice_primitive.go:594–617  ·  view source on GitHub ↗
(ctx *WriteContext, value reflect.Value, hasGenerics bool)

Source from the content-addressed store, hash-verified

592type stringSliceSerializer struct{}
593
594func (s stringSliceSerializer) writeDataWithGenerics(ctx *WriteContext, value reflect.Value, hasGenerics bool) {
595 v := stringSliceValue(value)
596 buf := ctx.Buffer()
597 length := len(v)
598 buf.WriteVarUint32(uint32(length))
599 if length == 0 {
600 return
601 }
602 // Write collection flags
603 // Note: Strings don't need reference tracking per xlang spec (NeedWriteRef(STRING) = false)
604 if hasGenerics {
605 // When element type is known from TypeDef, use CollectionDeclSameType and skip element type info
606 buf.WriteInt8(int8(CollectionDeclSameType))
607 } else {
608 // When element type is not known, write CollectionIsSameType and element type info
609 buf.WriteInt8(int8(CollectionIsSameType))
610 buf.WriteUint8(uint8(STRING))
611 }
612
613 // Write elements directly (no ref flag for strings)
614 for i := 0; i < length; i++ {
615 writeString(buf, v[i])
616 }
617}
618
619func (s stringSliceSerializer) WriteData(ctx *WriteContext, value reflect.Value) {
620 s.writeDataWithGenerics(ctx, value, false)

Callers 2

WriteDataMethod · 0.95
WriteMethod · 0.95

Calls 9

stringSliceValueFunction · 0.85
writeStringFunction · 0.85
WriteUint8Method · 0.80
uint32Function · 0.50
int8Function · 0.50
uint8Function · 0.50
BufferMethod · 0.45
WriteVarUint32Method · 0.45
WriteInt8Method · 0.45

Tested by

no test coverage detected