readFast reads a value using fast path based on DispatchId
(ptr unsafe.Pointer, ct DispatchId)
| 213 | |
| 214 | // readFast reads a value using fast path based on DispatchId |
| 215 | func (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 |
| 246 | func (c *ReadContext) ReadAndValidateTypeId(expected TypeId) { |
nothing calls this directly
no test coverage detected