skipSpaces skips whitespace characters.
()
| 648 | |
| 649 | // skipSpaces skips whitespace characters. |
| 650 | func (d *Decoder) skipSpaces() bool { |
| 651 | for { |
| 652 | b, ok := d.mustPeekBuffered() |
| 653 | if !ok { |
| 654 | return false |
| 655 | } |
| 656 | |
| 657 | found := false |
| 658 | for i, c := range b { |
| 659 | if !isSpace(c) { |
| 660 | // Found a non-space byte. |
| 661 | // Trim the bytes up to (but not including) this byte. |
| 662 | b = b[:i] |
| 663 | found = true |
| 664 | break |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | // Discard the spaces we've read. |
| 669 | if !d.discard(len(b)) { |
| 670 | return false |
| 671 | } |
| 672 | |
| 673 | if found { |
| 674 | // We've skipped all spaces, break the loop. |
| 675 | return true |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | // isSpace checks if a byte is a whitespace character. |
| 681 | func isSpace(b byte) bool { |
no test coverage detected