// pack8 packs 8 values from in using 7 bits each
540724
func pack8(src []uint64) uint64 {
	return 8<<60 |
		src[0] |
		src[1]<<7 |
		src[2]<<14 |
		src[3]<<21 |
		src[4]<<28 |
		src[5]<<35 |
		src[6]<<42 |
		src[7]<<49
}
343289
func (rwops *RWops) WriteU8(value uint8) uint {
	if rwops == nil {
		return 0
	}
	return uint(C.SDL_WriteU8(rwops.cptr(), C.Uint8(value)))
}
43888
func PackUInt64(cmd BufferEx, val uint64) (int, error) {
	return packUInt64(cmd, val)
}
519245
func (m *NamedValueInt) Pack() []byte {
	data := new(bytes.Buffer)
	binary.Write(data, binary.LittleEndian, m.TIME_BOOT_MS)
	binary.Write(data, binary.LittleEndian, m.VALUE)
	binary.Write(data, binary.LittleEndian, m.NAME)
	return data.Bytes()
}
1031338
func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte {
	if len(vals) == 0 {
		return append(dst, '[', ']')
	}
	dst = append(dst, '[')
	dst = strconv.AppendUint(dst, uint64(vals[0]), 10)
	if len(vals) > 1 {
		for _, val := range vals[1:] {
			dst = strconv.AppendUint(append(dst, ','), uint64(val), 10)
		}
	}
	dst = append(dst, ']')
	return dst
}
1072515
func (g *Group) Uint8() *Statement {
	// notest
	s := Uint8()
	g.items = append(g.items, s)
	return s
}
518185
func PackBytes(box string, name string, bb []byte) {
	gil.Lock()
	defer gil.Unlock()
	if _, ok := data[box]; !ok {
		data[box] = map[string][]byte{}
	}
	data[box][name] = bb
}
875873
func Uint8Bytes(v uint8) []byte {
	b := make([]byte, 1)
	PutUint8(b, v)
	return b
}
822840
func (tm intInterfaceMap) PackMap(buf BufferEx) (int, error) {
	size := 0
	for k, v := range tm {
		n, err := PackInt64(buf, int64(k))
		size += n
		if err != nil {
			return size, err
		}

		n, err = packObject(buf, v, false)
		size += n
		if err != nil {
			return size, err
		}
	}
	return size, nil
}
251437
func (ts float64Slice) PackList(buf BufferEx) (int, error) {
	size := 0
	for _, elem := range ts {
		n, err := PackFloat64(buf, elem)
		size += n
		if err != nil {
			return size, err
		}
	}
	return size, nil
}
44757
func Pack(w io.Writer, buf []byte) error {
	if len(buf) > messageMax {
		return errors.New("message is too large")
	}

	var bl [2]byte
	binary.LittleEndian.PutUint16(bl[:], uint16(len(buf)))
	_, err := w.Write(bl[:])
	if err != nil {
		return err
	}

	_, err = w.Write(buf)
	return err
}
1354192
func BEUvarint8(i uint8) []byte {
	dst := [1]byte{}
	binary.PutUvarint(dst[:], uint64(i))
	return dst[:]
}
556508
func (ae *AttributeEncoder) Uint8(typ uint16, v uint8) {
	if ae.err != nil {
		return
	}

	ae.attrs = append(ae.attrs, Attribute{
		Type: typ,
		Data: []byte{v},
	})
}
729088
func (c Context) Uint8(key string, i uint8) Context {
	c.l.context = enc.AppendUint8(enc.AppendKey(c.l.context, key), i)
	return c
}
1362938
func (tm uint64InterfaceMap) PackMap(buf BufferEx) (int, error) {
	size := 0
	for k, v := range tm {
		n, err := PackUInt64(buf, k)
		size += n
		if err != nil {
			return size, err
		}

		n, err = packObject(buf, v, false)
		size += n
		if err != nil {
			return size, err
		}
	}
	return size, nil
}
1244402
func (a *arrayHmnode) pack(idx int) hmnode {
	newArray := make([]interface{}, 2*(a.count-1))
	j := 1
	var bitmap uint32 = 0
	//TODO: change these to range iterations over subslices
	for i := 0; i < idx; i++ {
		if a.array[i] != nil {
			newArray[j] = a.array[i]
			bitmap = bitmap | 1<<uint32(i)
			j = j + 2
		}
	}
	for i := idx + 1; i < len(a.array); i++ {
		if a.array[i] != nil {
			newArray[j] = a.array[i]
			bitmap = bitmap | 1<<uint32(i)
			j = j + 2
		}
	}
	return &bitmapIndexedHmnode{bitmap, newArray}
}
631791
func (ts stringSlice) PackList(buf BufferEx) (int, error) {
	size := 0
	for _, elem := range ts {
		n, err := PackString(buf, elem)
		size += n
		if err != nil {
			return size, err
		}
	}
	return size, nil
}