// This hex encodes the binary data and writes the encoded data to the writer.
971138
func HexEncodeToWriter(w BinaryWriter, data []byte) {
	for _, b := range data {
		w.Write(hexMap[b])
	}
}
680791
func (dd *dictDecoder) WriteByte(c byte) {
	dd.hist[dd.wrPos] = c
	dd.wrPos++
}
128937
func (enc *Encoder) writeByte(c byte) {
	enc.buf = append(enc.buf, c)
}
996174
func (be *BinaryEncoder) WriteLong(x int64) {
	_, _ = be.buffer.Write(be.encodeVarint64(x))
}
217939
func (wr *Writer) Write(p []byte) (n int, err error) {
	wr.bf.Write(p)
	if bytes.HasSuffix(p, []byte(wr.lastElement)) {
		return wr.writer.Write([]byte(Format(wr.bf.String()) + "\n"))
	}
	return 0, nil
}
672892
func (be *BinaryEncoder) WriteInt(x int32) {
	_, _ = be.buffer.Write(be.encodeVarint32(x))
}
896095
func (enc *Encoder) writeBytes(p []byte) {
	enc.buf = append(enc.buf, p...)
}
152488
func (w *ByteWriter) Write(b []byte) (int, error) {
	p := w.grow(len(b))
	return copy(w.buf[p:], b), nil
}
496623
func WriteUint16(w io.Writer, value uint16) error {
	return binary.Write(w, binary.BigEndian, value)
}
812490
func binaryWrite(w io.Writer, order binary.ByteOrder, data interface{}) (n int64, err error) {
	buf := bytes.Buffer{}
	if err = binary.Write(&buf, order, data); err != nil {
		return 0, err
	}

	written, err := w.Write(buf.Bytes())
	return int64(written), err
}
1172283
func (c *chunkedIntCoder) Write(w io.Writer) (int, error) {
	bufNeeded := binary.MaxVarintLen64 * (1 + len(c.chunkLens))
	if len(c.buf) < bufNeeded {
		c.buf = make([]byte, bufNeeded)
	}
	buf := c.buf

	// convert the chunk lengths into chunk offsets
	chunkOffsets := modifyLengthsToEndOffsets(c.chunkLens)

	// write out the number of chunks & each chunk offsets
	n := binary.PutUvarint(buf, uint64(len(chunkOffsets)))
	for _, chunkOffset := range chunkOffsets {
		n += binary.PutUvarint(buf[n:], chunkOffset)
	}

	tw, err := w.Write(buf[:n])
	if err != nil {
		return tw, err
	}

	// write out the data
	nw, err := w.Write(c.final)
	tw += nw
	if err != nil {
		return tw, err
	}
	return tw, nil
}
463423
func (b *ByteBuf) WriteUInt64(v uint64) (n int, err error) {
	b.Expansion(8)
	Uint64ToBytesTo(v, b.buf[b.writerIndex:b.writerIndex+8])
	b.writerIndex += 8
	return 8, nil
}
1259386
func (stream *Stream) WriteUint8(val uint8) {
	stream.buf = writeFirstBuf(stream.buf, digits[val])
}
350746
func (w *Writer) Write(i interface{}) {
	var s string
	switch i.(type) {
	case string:
		s = i.(string)
	case []byte:
		for _, b := range i.([]byte) {
			s += fmt.Sprintf("%.8b", b)
		}
	case bool:
		if i.(bool) {
			s = "1"
		} else {
			s = "0"
		}
	case uint8:
		s = fmt.Sprintf("%.8b", i)
	case uint16:
		s = fmt.Sprintf("%.16b", i)
	case uint32:
		s = fmt.Sprintf("%.32b", i)
	case uint64:
		s = fmt.Sprintf("%.64b", i)
	default:
		return
	}

	for _, c := range s {
		w.remainingBits = w.remainingBits + string(c)
		if len(w.remainingBits) == 8 {
			var nb byte
			var power float64
			for idx := len(w.remainingBits) - 1; idx >= 0; idx-- {
				if w.remainingBits[idx] == '1' {
					nb = nb + uint8(math.Pow(2, power))
				}
				power++
			}
			w.b = append(w.b, nb)
			w.remainingBits = ""
		}
	}
}
1333973
func (w *VT100Writer) Write(data []byte) {
	w.WriteRaw(bytes.Replace(data, []byte{0x1b}, []byte{'?'}, -1))
	return
}
312374
func (meta *Meta) WriteBinary(w io.Writer) error {
	return binary.Write(w, byteorder.Native, meta)
}
180979
func (enc *Encoder) Write(p []byte) (n int, err error) {

	enc.mu.Lock()
	n, err = enc.writer.Write(p)

	if err != nil {
		enc.mu.Unlock()
		return
	}

	_, err = enc.writer.Write(endline)
	enc.mu.Unlock()

	return
}