| 658 | } |
| 659 | |
| 660 | func (p *gc_bin_parser) string() string { |
| 661 | if p.debugFormat { |
| 662 | p.marker('s') |
| 663 | } |
| 664 | // if the string was seen before, i is its index (>= 0) |
| 665 | // (the empty string is at index 0) |
| 666 | i := p.rawInt64() |
| 667 | if i >= 0 { |
| 668 | return p.strList[i] |
| 669 | } |
| 670 | // otherwise, i is the negative string length (< 0) |
| 671 | if n := int(-i); n <= cap(p.buf) { |
| 672 | p.buf = p.buf[:n] |
| 673 | } else { |
| 674 | p.buf = make([]byte, n) |
| 675 | } |
| 676 | for i := range p.buf { |
| 677 | p.buf[i] = p.rawByte() |
| 678 | } |
| 679 | s := string(p.buf) |
| 680 | p.strList = append(p.strList, s) |
| 681 | return s |
| 682 | } |
| 683 | |
| 684 | func (p *gc_bin_parser) marker(want byte) { |
| 685 | if got := p.rawByte(); got != want { |