// Get a byte slice from the pool.
327107
func (tp *BytePool) Get(size int) []byte {
	if size < 1 || size > tp.maxSize {
		return make([]byte, size)
	}
	var x []byte

	o := log2Ceil(uint32(size))
	p := &tp.list_of_pools[o]
	p.mu.Lock()
	if n := len(p.list); n > 0 {
		x = p.list[n-1]
		p.list[n-1] = nil
		p.list = p.list[:n-1]
	}
	p.mu.Unlock()
	if x == nil {
		x = make([]byte, 1<<o)
	}
	return x[:size]
}
427998
func Get() (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Get()
}
461316
func GetIntBytes(buf []byte, i int64) []byte {
	if i == 0 {
		return []byte{'0'}
	}
	if i == math.MinInt64 {
		return minInt64Buf[:]
	}
	var sign byte
	if i < 0 {
		sign = '-'
		i = -i
	}
	off := len(buf)
	var q, p int64
	for i >= 100 {
		q = i / 1000
		p = (i - (q * 1000)) * 3
		i = q
		off -= 3
		buf[off] = digit3[p]
		buf[off+1] = digit3[p+1]
		buf[off+2] = digit3[p+2]
	}
	if i >= 10 {
		q = i / 100
		p = (i - (q * 100)) * 2
		i = q
		off -= 2
		buf[off] = digit2[p]
		buf[off+1] = digit2[p+1]
	}
	if i > 0 {
		off--
		buf[off] = digits[i]
	}
	if sign == '-' {
		off--
		buf[off] = sign
	}
	return buf[off:]
}
723704
func (pool *IDPool) Get() (id uint32) {
	pool.Lock()
	defer pool.Unlock()

	// Pick a value that's been returned, if any.
	for key := range pool.used {
		delete(pool.used, key)
		return key
	}

	// No recycled IDs are available, so increase the pool size.
	pool.maxUsed += 1
	return pool.maxUsed
}
805981
func (p *Pool) getPool(addr string) *redis.Pool {

	defer scopedLock(&p.mutx)()

	pool, found := p.pools[addr]
	if !found {
		pool = redis.NewPool(func() (redis.Conn, error) {
			return p.dialFunc(addr)
		}, maxIdle)

		pool.TestOnBorrow = func(c redis.Conn, t time.Time) error {

			// for testing - count how many borrows we did
			atomic.AddInt64(&p.numBorrowed, 1)
			if time.Since(t) > testOnBorrowInterval {
				_, err := c.Do("PING")
				return err
			}
			return nil
		}

		p.pools[addr] = pool
	}

	return pool

}
1080147
func (bp *BytePool) Get() (b []byte) {
	select {
	case b = <-bp.c:
	// reuse existing buffer
	default:
		// create new buffer
		b = make([]byte, bp.w)
	}
	return
}
107686
func (q *BytesQueue) Get(index int) ([]byte, error) {
	data, _, err := q.peek(index)
	return data, err
}
728706
func GetRandomBytes(len int) ([]byte, error) {
	key := make([]byte, len)

	// TODO: rand could fill less bytes then len
	_, err := rand.Read(key)
	if err != nil {
		return nil, errors.Wrap(err, "error getting random bytes")
	}

	return key, nil
}
1368362
func (s Bytes) Get(i int) bool {
	return s[uint(i)>>byteShift]&(1<<(uint(i)&byteModMask)) != 0
}
1009531
func (_class PoolClass) GetAll(sessionID SessionRef) (_retval []PoolRef, _err error) {
	_method := "pool.get_all"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg)
	if _err != nil {
		return
	}
	_retval, _err = convertPoolRefSetToGo(_method + " -> ", _result.Value)
	return
}
998690
func getBytes(raw string) []byte {
	rawSlice := strings.FieldsFunc(raw, isArray)
	result := make([]byte, len(rawSlice))

	i := 0
	for _, b := range rawSlice {
		fmt.Sscan(b, &result[i])
		i++
	}
	return result
}
729879
func (t *RedconTransport) getPool(target string) (*redis.Pool, error) {
	t.mu.Lock()
	defer t.mu.Unlock()
	if t.closed {
		return nil, errors.New("closed")
	}
	pool, ok := t.pools[target]
	if !ok {
		pool = newTargetPool(target)
		t.pools[target] = pool
	}
	return pool, nil
}
1326728
func (b *bufp) Get() *bytes.Buffer {
	buffer := b.Pool.Get().(*bytes.Buffer)
	buffer.Reset()

	return buffer
}
483929
func (p *Pool) get(ctx context.Context) (*poolConn, error) {

	// Handle limit for p.Wait == true.
	var waited time.Duration
	if p.Wait && p.MaxActive > 0 {
		p.lazyInit()

		// wait indicates if we believe it will block so its not 100% accurate
		// however for stats it should be good enough.
		wait := len(p.ch) == 0
		var start time.Time
		if wait {
			start = time.Now()
		}
		if ctx == nil {
			<-p.ch
		} else {
			select {
			case <-p.ch:
			case <-ctx.Done():
				return nil, ctx.Err()
			}
		}
		if wait {
			waited = time.Since(start)
		}
	}

	p.mu.Lock()

	if waited > 0 {
		p.waitCount++
		p.waitDuration += waited
	}

	// Prune stale connections at the back of the idle list.
	if p.IdleTimeout > 0 {
		n := p.idle.count
		for i := 0; i < n && p.idle.back != nil && p.idle.back.t.Add(p.IdleTimeout).Before(nowFunc()); i++ {
			pc := p.idle.back
			p.idle.popBack()
			p.mu.Unlock()
			pc.c.Close()
			p.mu.Lock()
			p.active--
		}
	}

	// Get idle connection from the front of idle list.
	for p.idle.front != nil {
		pc := p.idle.front
		p.idle.popFront()
		p.mu.Unlock()
		if (p.TestOnBorrow == nil || p.TestOnBorrow(pc.c, pc.t) == nil) &&
			(p.MaxConnLifetime == 0 || nowFunc().Sub(pc.created) < p.MaxConnLifetime) {
			return pc, nil
		}
		pc.c.Close()
		p.mu.Lock()
		p.active--
	}

	// Check for pool closed before dialing a new connection.
	if p.closed {
		p.mu.Unlock()
		return nil, errors.New("redigo: get on closed pool")
	}

	// Handle limit for p.Wait == false.
	if !p.Wait && p.MaxActive > 0 && p.active >= p.MaxActive {
		p.mu.Unlock()
		return nil, ErrPoolExhausted
	}

	p.active++
	p.mu.Unlock()
	c, err := p.dial(ctx)
	if err != nil {
		c = nil
		p.mu.Lock()
		p.active--
		if p.ch != nil && !p.closed {
			p.ch <- struct{}{}
		}
		p.mu.Unlock()
	}
	return &poolConn{c: c, created: nowFunc()}, err
}
897386
func (err *Error) Get(k byte) (v string) {
	switch k {
	case 'S':
		return err.Severity
	case 'C':
		return string(err.Code)
	case 'M':
		return err.Message
	case 'D':
		return err.Detail
	case 'H':
		return err.Hint
	case 'P':
		return err.Position
	case 'p':
		return err.InternalPosition
	case 'q':
		return err.InternalQuery
	case 'W':
		return err.Where
	case 's':
		return err.Schema
	case 't':
		return err.Table
	case 'c':
		return err.Column
	case 'd':
		return err.DataTypeName
	case 'n':
		return err.Constraint
	case 'F':
		return err.File
	case 'L':
		return err.Line
	case 'R':
		return err.Routine
	}
	return ""
}
468302
func EncodeToBytes(val interface{}) ([]byte, error) {
	eb := encbufPool.Get().(*encbuf)
	defer encbufPool.Put(eb)
	eb.reset()
	if err := eb.encode(val); err != nil {
		return nil, err
	}
	return eb.toBytes(), nil
}
664982
func (b *Bucket) GetPool() *Pool {
	b.RLock()
	defer b.RUnlock()
	ret := b.pool
	return ret
}