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

Function WriteIntSlice

go/fory/slice_primitive.go:1228–1254  ·  view source on GitHub ↗

WriteIntSlice writes []int to buffer using ARRAY protocol

(buf *ByteBuffer, value []int)

Source from the content-addressed store, hash-verified

1226
1227// WriteIntSlice writes []int to buffer using ARRAY protocol
1228func WriteIntSlice(buf *ByteBuffer, value []int) {
1229 if strconv.IntSize == 64 {
1230 size := len(value) * 8
1231 buf.WriteLength(size)
1232 if len(value) > 0 {
1233 if isLittleEndian {
1234 buf.WriteBinary(unsafe.Slice((*byte)(unsafe.Pointer(&value[0])), size))
1235 } else {
1236 for i := 0; i < len(value); i++ {
1237 buf.WriteInt64(int64(value[i]))
1238 }
1239 }
1240 }
1241 } else {
1242 size := len(value) * 4
1243 buf.WriteLength(size)
1244 if len(value) > 0 {
1245 if isLittleEndian {
1246 buf.WriteBinary(unsafe.Slice((*byte)(unsafe.Pointer(&value[0])), size))
1247 } else {
1248 for i := 0; i < len(value); i++ {
1249 buf.WriteInt32(int32(value[i]))
1250 }
1251 }
1252 }
1253 }
1254}
1255
1256// ReadIntSlice reads []int from buffer using ARRAY protocol
1257func ReadIntSlice(buf *ByteBuffer, err *Error) []int {

Callers 3

WriteDataMethod · 0.85
SerializeFunction · 0.85
WriteIntSliceMethod · 0.85

Calls 7

SliceMethod · 0.80
int64Function · 0.50
int32Function · 0.50
WriteLengthMethod · 0.45
WriteBinaryMethod · 0.45
WriteInt64Method · 0.45
WriteInt32Method · 0.45

Tested by

no test coverage detected