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

Method readFast

go/fory/reader.go:215–243  ·  view source on GitHub ↗

readFast reads a value using fast path based on DispatchId

(ptr unsafe.Pointer, ct DispatchId)

Source from the content-addressed store, hash-verified

213
214// readFast reads a value using fast path based on DispatchId
215func (c *ReadContext) readFast(ptr unsafe.Pointer, ct DispatchId) {
216 err := c.Err()
217 switch ct {
218 case PrimitiveBoolDispatchId:
219 *(*bool)(ptr) = c.buffer.ReadBool(err)
220 case PrimitiveInt8DispatchId:
221 *(*int8)(ptr) = int8(c.buffer.ReadByte(err))
222 case PrimitiveInt16DispatchId:
223 *(*int16)(ptr) = c.buffer.ReadInt16(err)
224 case PrimitiveInt32DispatchId:
225 *(*int32)(ptr) = c.buffer.ReadVarint32(err)
226 case PrimitiveIntDispatchId:
227 if strconv.IntSize == 64 {
228 *(*int)(ptr) = int(c.buffer.ReadVarint64(err))
229 } else {
230 *(*int)(ptr) = int(c.buffer.ReadVarint32(err))
231 }
232 case PrimitiveInt64DispatchId:
233 *(*int64)(ptr) = c.buffer.ReadVarint64(err)
234 case PrimitiveFloat32DispatchId:
235 *(*float32)(ptr) = c.buffer.ReadFloat32(err)
236 case PrimitiveFloat64DispatchId:
237 *(*float64)(ptr) = c.buffer.ReadFloat64(err)
238 case PrimitiveFloat16DispatchId:
239 *(*uint16)(ptr) = c.buffer.ReadUint16(err)
240 case StringDispatchId:
241 *(*string)(ptr) = readString(c.buffer, err)
242 }
243}
244
245// ReadAndValidateTypeId reads type ID and validates it matches expected
246func (c *ReadContext) ReadAndValidateTypeId(expected TypeId) {

Callers

nothing calls this directly

Calls 11

ErrMethod · 0.95
readStringFunction · 0.85
ReadUint16Method · 0.80
int8Function · 0.50
ReadBoolMethod · 0.45
ReadByteMethod · 0.45
ReadInt16Method · 0.45
ReadVarint32Method · 0.45
ReadVarint64Method · 0.45
ReadFloat32Method · 0.45
ReadFloat64Method · 0.45

Tested by

no test coverage detected