summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBert Muthalaly <stijlist@google.com>2018-09-10 13:02:43 -0700
committerShentubot <shentubot@google.com>2018-09-10 13:04:06 -0700
commitda9ecb748cf6eb26e43338481d1ecba22eea09b2 (patch)
treea6f0e896fc876be7fcf8b33ad50644937381f813
parente198f9ab02874caeef65f16c0546af1e52e9a7d3 (diff)
Simplify some code in VectorisedView#ToView.
PiperOrigin-RevId: 212317717 Change-Id: Ic77449c53bf2f8be92c9f0a7a726c45bd35ec435
-rw-r--r--pkg/tcpip/buffer/view.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/pkg/tcpip/buffer/view.go b/pkg/tcpip/buffer/view.go
index d151b8cf0..4a921ddcb 100644
--- a/pkg/tcpip/buffer/view.go
+++ b/pkg/tcpip/buffer/view.go
@@ -154,13 +154,11 @@ func (vv *VectorisedView) Size() int {
// ToView returns a single view containing the content of the vectorised view.
func (vv *VectorisedView) ToView() View {
- v := make([]byte, vv.size)
- u := v
- for i := range vv.views {
- n := copy(u, vv.views[i])
- u = u[n:]
+ u := make([]byte, 0, vv.size)
+ for _, v := range vv.views {
+ u = append(u, v...)
}
- return v
+ return u
}
// Views returns the slice containing the all views.