// fill reads a new chunk into the buffer.
973734
func (b *Reader) fill() {
	// Slide existing data to beginning.
	if b.r > 0 {
		copy(b.buf, b.buf[b.r:b.w])
		b.w -= b.r
		b.r = 0
	}

	// Read new data.
	n, e := b.rd.Read(b.buf[b.w:])
	b.w += n
	if e != nil {
		b.err = e
	}
}
181140
func (cb *CellBuffer) Fill(r rune, style Style) {
	for i := range cb.cells {
		c := &cb.cells[i]
		c.currMain = r
		c.currComb = nil
		c.currStyle = style
		c.width = 1
	}
}
484977
func (f *Selectable) Fill(v interface{}, e error) error {
	f.m.Lock()
	if f.filled == 0 {
		f.val = v
		f.err = e
		atomic.StoreUint32(&f.filled, 1)
		w := f.wait
		f.wait = closed
		if w != nil {
			close(w)
		}
	}
	f.m.Unlock()
	return f.err
}
709599
func (p *ReadBuffer) Take() *buffer.Read {
	return p.pool.Take().(*buffer.Read)
}
808409
func (l *State) Load(r io.Reader, chunkName string, mode string) error {
	if chunkName == "" {
		chunkName = "?"
	}

	if err := protectedParser(l, r, chunkName, mode); err != nil {
		return err
	}

	if f := l.stack[l.top-1].(*luaClosure); f.upValueCount() == 1 {
		f.setUpValue(0, l.global.registry.atInt(RegistryIndexGlobals))
	}
	return nil
}
1249030
func (p *Parser) fill() {
	p.offs += p.bsp
	left := len(p.bs) - p.bsp
	copy(p.readBuf[:left], p.readBuf[p.bsp:])
readAgain:
	n, err := 0, p.readErr
	if err == nil {
		n, err = p.src.Read(p.readBuf[left:])
		p.readErr = err
	}
	if n == 0 {
		if err == nil {
			goto readAgain
		}
		// don't use p.errPass as we don't want to overwrite p.tok
		if err != io.EOF {
			p.err = err
		}
		if left > 0 {
			p.bs = p.readBuf[:left]
		} else {
			p.bs = nil
		}
	} else {
		p.bs = p.readBuf[:left+n]
	}
	p.bsp = 0
}
431196
func (p *WriteBuffer) Take() *buffer.Write {
	return p.pool.Take().(*buffer.Write)
}
688530
func (d *Decoder) Read(p []byte) (int, error) {
	if d.stream == nil {
		return 0, errors.New("no input has been initialized")
	}
	var n int
	for {
		if len(d.current.b) > 0 {
			filled := copy(p, d.current.b)
			p = p[filled:]
			d.current.b = d.current.b[filled:]
			n += filled
		}
		if len(p) == 0 {
			break
		}
		if len(d.current.b) == 0 {
			// We have an error and no more data
			if d.current.err != nil {
				break
			}
			d.nextBlock()
		}
	}
	if len(d.current.b) > 0 {
		// Only return error at end of block
		return n, nil
	}
	if d.current.err != nil {
		d.drainOutput()
	}
	if debug {
		println("returning", n, d.current.err, len(d.decoders))
	}
	return n, d.current.err
}
1322522
func (b *buffer) grow(n int) {
	for n > len(b.data) {
		b.data = b.data[:len(b.data)+BufferLen]
	}
}
205642
func (g *groupReader) fill() bool {
	if g.next == nil {
		g.next = <-g.reader.C()
	}
	if g.next == nil {
		return false
	} else {
		g.key = g.tokey(g.next)
	}
	g.group = []Record{g.next}
	for {
		g.next = <-g.reader.C()
		var k []string
		if g.next != nil {
			k = g.tokey(g.next)
		}
		if g.next == nil || g.less(k, g.key) || g.less(g.key, k) {
			return true
		} else {
			g.group = append(g.group, g.next)
		}
	}
}
1073453
func (c *TermVectorsConsumer) fill(docId int) error {
	for c.lastDocId < docId {
		c.writer.StartDocument(0)
		err := c.writer.FinishDocument()
		if err != nil {
			return err
		}
		c.lastDocId++
	}
	return nil
}
1184276
func (b *LookAheadBuffer) Consume(numBytes int) error {
	if numBytes == 0 {
		return nil
	}
	if numBytes < 0 {
		return errors.New("Cannot drop negative numBytes")
	}
	if b.bytesBuffered < numBytes {
		return errors.New("Consuming more bytes than bytes in buffer.")
	}

	copy(b.buffer, b.buffer[numBytes:b.bytesBuffered])
	b.bytesBuffered -= numBytes
	return nil
}
825121
func FillStruct(s interface{}, m map[string]interface{}) error {
	for k, v := range m {
		err := SetField(s, k, v)
		if err != nil {
			return err
		}
	}
	return nil
}
856632
func (rd *reservoirReader) load(n int) error {
	m, err := rd.stream.readBytes(rd.buffer[rd.limit : rd.limit+n])
	rd.limit += m
	return err
}
1231573
func (bp *SizedBufferPool) Put(b *bytes.Buffer) {
	b.Reset()

	// Release buffers over our maximum capacity and re-create a pre-sized
	// buffer to replace it.
	// Note that the cap(b.Bytes()) provides the capacity from the read off-set
	// only, but as we've called b.Reset() the full capacity of the underlying
	// byte slice is returned.
	if cap(b.Bytes()) > bp.a {
		b = bytes.NewBuffer(make([]byte, 0, bp.a))
	}

	select {
	case bp.c <- b:
	default: // Discard the buffer if the pool is full.
	}
}
1182327
func (bp *BufferPool) Put(b *bytes.Buffer) {
	b.Reset()

	if cap(b.Bytes()) > bp.alloc {
		b = bytes.NewBuffer(make([]byte, 0, bp.alloc))
	}

	select {
	case bp.c <- b:
	default: // Discard the buffer if the pool is full.
	}
}
685799
func (c *Chunk) Insert(rowIdx int, row Row) {
	for i, srcCol := range row.c.columns {
		if row.IsNull(i) {
			continue
		}
		dstCol := c.columns[i]
		var srcStart, srcEnd, destStart, destEnd int
		if srcCol.isFixed() {
			srcElemLen, destElemLen := len(srcCol.elemBuf), len(dstCol.elemBuf)
			srcStart, destStart = row.idx*srcElemLen, rowIdx*destElemLen
			srcEnd, destEnd = srcStart+srcElemLen, destStart+destElemLen
		} else {
			srcStart, srcEnd = int(srcCol.offsets[row.idx]), int(srcCol.offsets[row.idx+1])
			destStart, destEnd = int(dstCol.offsets[rowIdx]), int(dstCol.offsets[rowIdx+1])
		}
		copy(dstCol.data[destStart:destEnd], srcCol.data[srcStart:srcEnd])
	}
}