mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
ByteBuffer.Truncate(n int)
R=r DELTA=22 (17 added, 0 deleted, 5 changed) OCL=28781 CL=28815
This commit is contained in:
parent
a8db4593ab
commit
28db3e8411
2 changed files with 22 additions and 5 deletions
|
|
@ -39,9 +39,17 @@ func (b *ByteBuffer) Len() int {
|
|||
return len(b.buf) - b.off
|
||||
}
|
||||
|
||||
// Truncates the buffer so it contains n bytes.
|
||||
// It preserves the data in the buffer at positions [0 : n].
|
||||
// It is an error to call b.Truncate(n) with n > b.Len().
|
||||
func (b *ByteBuffer) Truncate(n int) {
|
||||
b.buf = b.buf[0 : b.off + n];
|
||||
}
|
||||
|
||||
// Reset resets the buffer so it has no content.
|
||||
// b.Reset() is the same as b.Truncate(0).
|
||||
func (b *ByteBuffer) Reset() {
|
||||
b.off = len(b.buf)
|
||||
b.buf = b.buf[0 : b.off];
|
||||
}
|
||||
|
||||
// Write appends the contents of p to the buffer. The return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue