TakeRedactableString returns the buffer contents and reinitializes the buffer. This saves a memory allocation compared to RedactableString().
()
| 100 | // contents and reinitializes the buffer. This saves |
| 101 | // a memory allocation compared to RedactableString(). |
| 102 | func (b *Buffer) TakeRedactableString() m.RedactableString { |
| 103 | if b == nil { |
| 104 | // Special case, useful in debugging. |
| 105 | return "<nil>" |
| 106 | } |
| 107 | b.finalize() |
| 108 | r := *(*m.RedactableString)(unsafe.Pointer(&b.buf)) |
| 109 | b.buf = nil |
| 110 | b.validUntil = 0 |
| 111 | b.mode = UnsafeEscaped |
| 112 | return r |
| 113 | } |
| 114 | |
| 115 | // Len returns the number of bytes in the buffer. |
| 116 | func (b *Buffer) Len() int { |