github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/pkg/compress/flate/copy.go (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package flate
     6  
     7  // forwardCopy is like the built-in copy function except that it always goes
     8  // forward from the start, even if the dst and src overlap.
     9  func forwardCopy(dst, src []byte) int {
    10  	if len(src) > len(dst) {
    11  		src = src[:len(dst)]
    12  	}
    13  	for i, x := range src {
    14  		dst[i] = x
    15  	}
    16  	return len(src)
    17  }