WriteIntSlice writes []int to buffer using ARRAY protocol
(buf *ByteBuffer, value []int)
| 1226 | |
| 1227 | // WriteIntSlice writes []int to buffer using ARRAY protocol |
| 1228 | func 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 |
| 1257 | func ReadIntSlice(buf *ByteBuffer, err *Error) []int { |
no test coverage detected