// PeekRune returns the rune and rune length of the ith byte relative to the end position.
438074
func (z *StreamLexer) PeekRune(pos int) (rune, int) {
	// from unicode/utf8
	c := z.Peek(pos)
	if c < 0xC0 {
		return rune(c), 1
	} else if c < 0xE0 {
		return rune(c&0x1F)<<6 | rune(z.Peek(pos+1)&0x3F), 2
	} else if c < 0xF0 {
		return rune(c&0x0F)<<12 | rune(z.Peek(pos+1)&0x3F)<<6 | rune(z.Peek(pos+2)&0x3F), 3
	}
	return rune(c&0x07)<<18 | rune(z.Peek(pos+1)&0x3F)<<12 | rune(z.Peek(pos+2)&0x3F)<<6 | rune(z.Peek(pos+3)&0x3F), 4
}
821663
func peek(b []byte) (length int, err error) {
	if len(b) < 1 {
		return 0, errors.New("invalid encoded key")
	}
	flag := b[0]
	length++
	b = b[1:]
	var l int
	switch flag {
	case NilFlag:
	case intFlag, uintFlag, floatFlag, durationFlag:
		// Those types are stored in 8 bytes.
		l = 8
	case bytesFlag:
		l, err = peekBytes(b, false)
	case compactBytesFlag:
		l, err = peekCompactBytes(b)
	case decimalFlag:
		l, err = types.DecimalPeak(b)
	case varintFlag:
		l, err = peekVarint(b)
	case uvarintFlag:
		l, err = peekUvarint(b)
	default:
		return 0, errors.Errorf("invalid encoded key flag %v", flag)
	}
	if err != nil {
		return 0, errors.Trace(err)
	}
	length += l
	return
}
30304
func (r *reader) peek() rune {
	if r.eof() {
		return unicode.ReplacementChar
	}
	v, w := rune(r.s[r.p.Offset]), 1
	switch {
	case v == 0:
		r.w = w
		return v // illegal UTF-8 encoding
	case v >= 0x80:
		v, w = utf8.DecodeRuneInString(r.s[r.p.Offset:])
		if v == utf8.RuneError && w == 1 {
			v = rune(r.s[r.p.Offset]) // illegal UTF-8 encoding
		}
	}
	r.w = w
	return v
}
723476
func (q Queue) PeekN(n int) (msgs []*Message, err error) {
	msgs, err = q.PeekNWithTimeout(n, 0)

	return
}
1353200
func (l *Lexer) peekRunePast(skip int) rune {
	if l.pos+skip+1 > len(l.input) {
		return rune(0)
	}

	for ; skip < len(l.input)-l.pos; skip++ {
		r, ri := utf8.DecodeRuneInString(l.input[l.pos+skip:])
		if ri != 1 {
			skip += (ri - 1)
		}
		if !unicode.IsSpace(r) {
			return r
		}
	}
	return rune(0)
}
77191
func (s *Scanner) peekIgnoreWhitespace() rune {
	var b []byte
	if s.i < len(s.b) {
		b = s.b[s.i:]
	}

	for i := 0; ; i++ {
		if len(b) == 0 {
			return eof
		}

		ch, sz := utf8.DecodeRune(b)
		if !isWhitespace(ch) {
			return ch
		}

		b = b[sz:]
	}
}
1355320
func (z *StreamLexer) Peek(pos int) byte {
	pos += z.pos
	if uint(pos) < uint(len(z.buf)) { // uint for BCE
		return z.buf[pos]
	}
	return z.read(pos)
}
243591
func (s *Scanner) Peek() rune {
	r, _, _ := s.r.ReadRune()
	if r != eof {
		_ = s.r.UnreadRune()
	}

	return r
}
840640
func (l *Scanner) Peek() byte {
	if l.pos == len(l.data) {
		return 0
	}
	return l.data[l.pos]
}
1160769
func (c *ARCCache) Peek(key interface{}) (value interface{}, ok bool) {
	c.lock.RLock()
	defer c.lock.RUnlock()
	if val, ok := c.t1.Peek(key); ok {
		return val, ok
	}
	return c.t2.Peek(key)
}
1203376
func (s *scanner) peekPos() int {
	if s.readPos >= len(s.stateRecord){
		return  s.cacheRecord.pos// peek can be called when the array is over , only if unmarshal error occured, so return last read position 
	}
	if !s.cached {
		s.cached = true
		s.cacheRecord = s.stateRecord[s.readPos]
	}
	return s.cacheRecord.pos
}
169221
func (p *Parser) PeekN(shift int, typ TokenType, val string) *Token {
	t := p.Get(p.idx + shift)
	if t != nil {
		if t.Typ == typ && t.Val == val {
			return t
		}
	}
	return nil
}
1313161
func (c *Conn) Peek(id uint64) (body []byte, err error) {
	r, err := c.cmd(nil, nil, nil, "peek", id)
	if err != nil {
		return nil, err
	}
	return c.readResp(r, true, "FOUND %d", &id)
}
215090
func (b *ByteBuf) PeekInt(offset int) (int, error) {
	if b.Readable() < 4+offset {
		return 0, io.ErrShortBuffer
	}

	start := b.readerIndex + offset
	return Byte2Int(b.buf[start : start+4]), nil
}
973693
func (r *reader) ReadRune() (ch rune, size int, err error) {
	ch, _ = r.read()
	if ch == eof {
		err = io.EOF
	}
	return
}
1013718
func (b *Buffer) Peek() (interface{}, error) {
	var ln int
	var v interface{}

	b.rw.RLock()
	{
		if ln = len(b.buffer); ln > 0 {
			v = b.buffer[0]
		}
	}
	b.rw.RUnlock()

	if ln == 0 {
		return nil, ErrBufferEmpty
	}

	return v, nil
}
185367
func (r *ReverseReader) ReadRune() (ru rune, size int, err error) {
	var rb [4]byte
	n, err := r.Read(rb[:])
	ru, size = utf8.DecodeLastRune(rb[:n])
	if err != nil {
		return
	}
	r.offset += int64(n - size)
	r.rs.Seek(r.offset, os.SEEK_SET)
	if ru == utf8.RuneError {
		return ru, size, fmt.Errorf("RuneError")
	}
	return
}