// ReadVarInt32 tries to read a int32 from r.
490102
func ReadVarInt32(r io.Reader) (int32, error) {
	i64, err := ReadVarInt64(r)
	if err != nil {
		return 0, err
	}
	return int32(i64), nil
}
876661
func (s *Session) Int32(key string) int32 {
	s.RLock()
	defer s.RUnlock()

	v, ok := s.data[key]
	if !ok {
		return 0
	}

	value, ok := v.(int32)
	if !ok {
		return 0
	}
	return value
}
259065
func (p *TCompactProtocol) readVarint32() (int32, error) {
	// if the wire contains the right stuff, this will just truncate the i64 we
	// read and get us the right sign.
	v, err := p.readVarint64()
	return int32(v), err
}
867285
func (s StringStringMap) GetInt32(key string) (int32, error) {
	return s.getInt32(key, false)
}
1304138
func (dec *Decoder) DecodeInt32(v *int32) error {
	if dec.isPooled == 1 {
		panic(InvalidUsagePooledDecoderError("Invalid usage of pooled decoder"))
	}
	return dec.decodeInt32(v)
}
1304458
func MustReadVarUint32(r io.Reader) uint32 {
	u32, err := ReadVarUint32(r)
	if err != nil {
		panic(err)
	}
	return u32
}
977384
func (b *ByteBuf) ReadUInt32() (uint32, error) {
	if b.Readable() < 4 {
		return 0, io.ErrShortBuffer
	}

	b.readerIndex += 4
	return Byte2UInt32(b.buf[b.readerIndex-4 : b.readerIndex]), nil
}
7225
func (b byteReader) Int32() int32 {
	b2 := b.b[b.off : b.off+4 : b.off+4]
	v3 := int32(b2[3])
	v2 := int32(b2[2])
	v1 := int32(b2[1])
	v0 := int32(b2[0])
	return v0 | (v1 << 8) | (v2 << 16) | (v3 << 24)
}
770727
func (vb *keyWriter) WriteInt32(num int32) (int, error) {
	return vb.WriteUint32(uint32(num))
}
758318
func (iter *Iterator) ReadFloat32() (ret float32) {
	c := iter.nextToken()
	if c == '-' {
		return -iter.readPositiveFloat32()
	}
	iter.unreadByte()
	return iter.readPositiveFloat32()
}
572003
func (r *reader) readVarInt64() int64 {
	ux := r.readVarUint64()
	x := int64(ux >> 1)
	if ux&1 != 0 {
		x = ^x
	}
	return x
}
79256
func IndexOfInt32(a []int32, x int32) int {
	return indexOf(len(a), func(i int) bool { return a[i] == x })
}
822803
func ReadInt(r io.Reader) (int, error) {
	data, err := ReadN(r, 4)

	if err != nil {
		return 0, err
	}

	return Byte2Int(data), nil
}
1310984
func (p *TCompactProtocol) readVarint64() (int64, error) {
	shift := uint(0)
	result := int64(0)
	for {
		b, err := p.ReadByte()
		if err != nil {
			return 0, err
		}
		result |= int64(b&0x7f) << shift
		if (b & 0x80) != 0x80 {
			break
		}
		shift += 7
	}
	return result, nil
}
1363430
func readInt32(r io.Reader) (int, error) {
	var value int32
	err := binary.Read(r, binary.LittleEndian, &value)
	return int(value), err
}
240229
func readVarInt(r io.Reader) (uint64, int, error) {
	var b [8]byte
	_, err := io.ReadFull(r, b[0:1])
	if err != nil {
		return 0, 1, err
	}

	var rv uint64
	var n int // number of bytes
	discriminant := uint8(b[0])
	switch discriminant {
	case 0xff:
		n = 9
		_, err := io.ReadFull(r, b[:])
		if err != nil {
			return 0, n, err
		}
		rv = binary.LittleEndian.Uint64(b[:])

		// The encoding is not canonical if the value could have been
		// encoded using fewer bytes
		min := uint64(0x100000000)
		if rv < min {
			return 0, n, fmt.Errorf("readVarInt: %d, %d, %d", rv, discriminant, min)
		}

	case 0xfe:
		n = 5
		_, err := io.ReadFull(r, b[0:4])
		if err != nil {
			return 0, n, err
		}
		rv = uint64(binary.LittleEndian.Uint32(b[:]))

		// The encoding is not canonical if the value could have been
		// encoded using fewer bytes
		min := uint64(0x10000)
		if rv < min {
			return 0, n, fmt.Errorf("readVarInt: %d, %d, %d", rv, discriminant, min)
		}

	case 0xfd:
		n = 3
		_, err := io.ReadFull(r, b[0:2])
		if err != nil {
			return 0, n, err
		}
		rv = uint64(binary.LittleEndian.Uint16(b[:]))

		// The encoding is not canonical if the value could have been
		// encoded using fewer bytes
		min := uint64(0xfd)
		if rv < min {
			return 0, n, fmt.Errorf("readVarInt: %d, %d, %d", rv, discriminant, min)
		}

	default:
		rv = uint64(discriminant)
		n = 1
	}

	return rv, n, nil
}
879464
func (b *Buffer) Read32() uint32 {
	v, ok := b.consume(4)
	if !ok {
		return 0
	}
	return order.Uint32(v)
}