From da9ecb748cf6eb26e43338481d1ecba22eea09b2 Mon Sep 17 00:00:00 2001 From: Bert Muthalaly Date: Mon, 10 Sep 2018 13:02:43 -0700 Subject: Simplify some code in VectorisedView#ToView. PiperOrigin-RevId: 212317717 Change-Id: Ic77449c53bf2f8be92c9f0a7a726c45bd35ec435 --- pkg/tcpip/buffer/view.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'pkg') 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. -- cgit v1.2.3