summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/buffer/prependable.go
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@google.com>2018-09-14 16:38:45 -0700
committerShentubot <shentubot@google.com>2018-09-14 16:39:56 -0700
commit75c66f871b56a8f4e83dc9ccec29cf3d2c38fea4 (patch)
tree137a5e51dcc786e76bc96e34ac36be8fdb5ac304 /pkg/tcpip/buffer/prependable.go
parent3aa50f18a4102429aa40f5d0e518357ceaed2373 (diff)
Remove buffer.Prependable.UsedBytes
It is the same as buffer.Prependable.View. PiperOrigin-RevId: 213064166 Change-Id: Ib33b8a2c4da864209d9a0be0a1c113be10b520d3
Diffstat (limited to 'pkg/tcpip/buffer/prependable.go')
-rw-r--r--pkg/tcpip/buffer/prependable.go30
1 files changed, 11 insertions, 19 deletions
diff --git a/pkg/tcpip/buffer/prependable.go b/pkg/tcpip/buffer/prependable.go
index bca23ef68..c5dd2819f 100644
--- a/pkg/tcpip/buffer/prependable.go
+++ b/pkg/tcpip/buffer/prependable.go
@@ -41,28 +41,9 @@ func NewPrependableFromView(v View) Prependable {
return Prependable{buf: v, usedIdx: 0}
}
-// Prepend reserves the requested space in front of the buffer, returning a
-// slice that represents the reserved space.
-func (p *Prependable) Prepend(size int) []byte {
- if size > p.usedIdx {
- return nil
- }
-
- p.usedIdx -= size
- return p.buf[p.usedIdx:][:size:size]
-}
-
// View returns a View of the backing buffer that contains all prepended
// data so far.
func (p Prependable) View() View {
- v := p.buf
- v.TrimFront(p.usedIdx)
- return v
-}
-
-// UsedBytes returns a slice of the backing buffer that contains all prepended
-// data so far.
-func (p Prependable) UsedBytes() []byte {
return p.buf[p.usedIdx:]
}
@@ -70,3 +51,14 @@ func (p Prependable) UsedBytes() []byte {
func (p Prependable) UsedLength() int {
return len(p.buf) - p.usedIdx
}
+
+// Prepend reserves the requested space in front of the buffer, returning a
+// slice that represents the reserved space.
+func (p *Prependable) Prepend(size int) []byte {
+ if size > p.usedIdx {
+ return nil
+ }
+
+ p.usedIdx -= size
+ return p.View()[:size:size]
+}