safeAddByteString is no-alloc equivalent of safeAddString(string(s)) for s []byte.
(s []byte)
| 496 | |
| 497 | // safeAddByteString is no-alloc equivalent of safeAddString(string(s)) for s []byte. |
| 498 | func (enc *jsonEncoder) safeAddByteString(s []byte) { |
| 499 | safeAppendStringLike( |
| 500 | (*buffer.Buffer).AppendBytes, |
| 501 | utf8.DecodeRune, |
| 502 | enc.buf, |
| 503 | s, |
| 504 | ) |
| 505 | } |
| 506 | |
| 507 | // safeAppendStringLike is a generic implementation of safeAddString and safeAddByteString. |
| 508 | // It appends a string or byte slice to the buffer, escaping all special characters. |