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

Method WriteByte

internal/buffer/buffer.go:153–168  ·  view source on GitHub ↗

WriteByte emits a single byte.

(s byte)

Source from the content-addressed store, hash-verified

151
152// WriteByte emits a single byte.
153func (b *Buffer) WriteByte(s byte) error {
154 b.startWrite()
155 if b.mode == UnsafeEscaped &&
156 (s >= utf8.RuneSelf ||
157 s == m.StartS[0] || s == m.EndS[0]) {
158 // Unsafe byte. Escape it.
159 _, err := b.WriteString(m.EscapeMarkS)
160 return err
161 }
162 m, ok := b.tryGrowByReslice(1)
163 if !ok {
164 m = b.grow(1)
165 }
166 b.buf[m] = s
167 return nil
168}
169
170// WriteRune emits a single rune.
171func (b *Buffer) WriteRune(s rune) error {

Callers 10

TestBufferUnsafeWritesFunction · 0.95
TestBufferRawSafeWritesFunction · 0.95
Example_mixed_writesFunction · 0.95
MakeFormatFunction · 0.45
SafeByteMethod · 0.45
UnsafeByteMethod · 0.45
writeByteMethod · 0.45
fmtSbxMethod · 0.45

Calls 4

startWriteMethod · 0.95
WriteStringMethod · 0.95
tryGrowByResliceMethod · 0.95
growMethod · 0.95

Tested by 5

TestBufferUnsafeWritesFunction · 0.76
TestBufferRawSafeWritesFunction · 0.76
Example_mixed_writesFunction · 0.76