MCPcopy Create free account
hub / github.com/cockroachdb/redact / TakeRedactableString

Method TakeRedactableString

internal/buffer/buffer.go:102–113  ·  view source on GitHub ↗

TakeRedactableString returns the buffer contents and reinitializes the buffer. This saves a memory allocation compared to RedactableString().

()

Source from the content-addressed store, hash-verified

100// contents and reinitializes the buffer. This saves
101// a memory allocation compared to RedactableString().
102func (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.
116func (b *Buffer) Len() int {

Callers 5

SprintfnFunction · 0.80
HelperForErrorfFunction · 0.80
SprintfFunction · 0.80
SprintFunction · 0.80
SprintlnFunction · 0.80

Calls 1

finalizeMethod · 0.95

Tested by

no test coverage detected