(ctx *WriteContext, value reflect.Value, hasGenerics bool)
| 83 | } |
| 84 | |
| 85 | func (s setSerializer) writeDataWithGenerics(ctx *WriteContext, value reflect.Value, hasGenerics bool) { |
| 86 | buf := ctx.Buffer() |
| 87 | // Get all map keys (set elements) |
| 88 | keys := value.MapKeys() |
| 89 | length := len(keys) |
| 90 | |
| 91 | // Handle empty set case |
| 92 | if length == 0 { |
| 93 | buf.WriteVarUint32(0) // WriteData 0 length for empty set |
| 94 | return |
| 95 | } |
| 96 | |
| 97 | // WriteData collection header and get type information |
| 98 | collectFlag, elemTypeInfo := s.writeHeader(ctx, buf, keys, hasGenerics) |
| 99 | |
| 100 | // Check if all elements are of same type |
| 101 | if (collectFlag & CollectionIsSameType) != 0 { |
| 102 | // Optimized path for same-type elements |
| 103 | s.writeSameType(ctx, buf, keys, elemTypeInfo, collectFlag) |
| 104 | return |
| 105 | } |
| 106 | // Fallback path for mixed-type elements |
| 107 | s.writeDifferentTypes(ctx, buf, keys, collectFlag) |
| 108 | } |
| 109 | |
| 110 | func (s setSerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) { |
| 111 | if refMode != RefModeNone { |
no test coverage detected