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

Method writeFast

go/fory/writer.go:183–211  ·  view source on GitHub ↗

writeFast writes a value using fast path based on DispatchId

(ptr unsafe.Pointer, ct DispatchId)

Source from the content-addressed store, hash-verified

181
182// writeFast writes a value using fast path based on DispatchId
183func (c *WriteContext) writeFast(ptr unsafe.Pointer, ct DispatchId) {
184 switch ct {
185 case PrimitiveBoolDispatchId:
186 c.buffer.WriteBool(*(*bool)(ptr))
187 case PrimitiveInt8DispatchId:
188 c.buffer.WriteByte_(*(*byte)(ptr))
189 case PrimitiveInt16DispatchId:
190 c.buffer.WriteInt16(*(*int16)(ptr))
191 case PrimitiveInt32DispatchId:
192 c.buffer.WriteVarint32(*(*int32)(ptr))
193 case PrimitiveIntDispatchId:
194 if strconv.IntSize == 64 {
195 c.buffer.WriteVarint64(int64(*(*int)(ptr)))
196 } else {
197 c.buffer.WriteVarint32(int32(*(*int)(ptr)))
198 }
199 case PrimitiveInt64DispatchId:
200 c.buffer.WriteVarint64(*(*int64)(ptr))
201 case PrimitiveFloat32DispatchId:
202 c.buffer.WriteFloat32(*(*float32)(ptr))
203 case PrimitiveFloat64DispatchId:
204 c.buffer.WriteFloat64(*(*float64)(ptr))
205 case PrimitiveFloat16DispatchId:
206 // Float16 is uint16 in Go
207 c.buffer.WriteUint16(*(*uint16)(ptr))
208 case StringDispatchId:
209 writeString(c.buffer, *(*string)(ptr))
210 }
211}
212
213// WriteLength writes a length value as varint (non-negative values)
214func (c *WriteContext) WriteLength(length int) {

Callers

nothing calls this directly

Calls 11

writeStringFunction · 0.85
WriteBoolMethod · 0.80
WriteByte_Method · 0.80
WriteUint16Method · 0.80
int64Function · 0.50
int32Function · 0.50
WriteInt16Method · 0.45
WriteVarint32Method · 0.45
WriteVarint64Method · 0.45
WriteFloat32Method · 0.45
WriteFloat64Method · 0.45

Tested by

no test coverage detected