append appends r to b.Buffer separated by sep when b.Buffer is not already empty. Dynamically grows b.Buf as necessary to accommodate r and the separator. Specifically, when b.Buf is not empty, b.Buf will grow by increments of MinCapIncrease. After a call to append, b.Len will be len(b.Buf)+len(se
(r, sep []rune)
| 240 | // After a call to append, b.Len will be len(b.Buf)+len(sep)+len(r). Call Reset |
| 241 | // to reset the Buf. |
| 242 | func (b *Batcher) append(r, sep []rune) { |
| 243 | rlen := len(r) |
| 244 | // initial |
| 245 | if b.buffer == nil { |
| 246 | b.buffer, b.length = r, rlen |
| 247 | b.beginByteOffset = b.firstByteOffset |
| 248 | return |
| 249 | } |
| 250 | blen, seplen := b.length, len(sep) |
| 251 | tlen := blen + rlen + seplen |
| 252 | // grow |
| 253 | if bcap := cap(b.buffer); tlen > bcap { |
| 254 | n := tlen + 2*rlen |
| 255 | n += minCapIncrease - (n % minCapIncrease) |
| 256 | z := make([]rune, blen, n) |
| 257 | copy(z, b.buffer) |
| 258 | b.buffer = z |
| 259 | } |
| 260 | b.buffer = b.buffer[:tlen] |
| 261 | copy(b.buffer[blen:], sep) |
| 262 | copy(b.buffer[blen+seplen:], r) |
| 263 | b.length = tlen |
| 264 | } |
| 265 | |
| 266 | // readString seeks to the end of a string returning the position and whether |
| 267 | // or not the string's end was found. |
no outgoing calls