countNewLines counts the number of new lines in the given byte slice and increments the decoder's line counter accordingly.
(b []byte)
| 862 | // countNewLines counts the number of new lines in the given byte slice |
| 863 | // and increments the decoder's line counter accordingly. |
| 864 | func (d *Decoder) countNewLines(b []byte) { |
| 865 | // Somehow this is more efficient than bytes.Count... |
| 866 | for { |
| 867 | ind := bytes.IndexByte(b, '\n') |
| 868 | if ind < 0 { |
| 869 | break |
| 870 | } |
| 871 | d.line++ |
| 872 | b = b[ind+1:] |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | // setSyntaxErrorf sets a syntax error with the current line number. |
| 877 | func (d *Decoder) setSyntaxErrorf(format string, a ...any) { |