writeFast writes a value using fast path based on DispatchId
(ptr unsafe.Pointer, ct DispatchId)
| 181 | |
| 182 | // writeFast writes a value using fast path based on DispatchId |
| 183 | func (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) |
| 214 | func (c *WriteContext) WriteLength(length int) { |
nothing calls this directly
no test coverage detected