summaryrefslogtreecommitdiff
path: root/src/pkg/compress/flate/copy.go
blob: 06e5d2e66d9fd54284a1f8c8aa3dd7110ffe715d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package flate

// forwardCopy is like the built-in copy function except that it always goes
// forward from the start, even if the dst and src overlap.
func forwardCopy(dst, src []byte) int {
	if len(src) > len(dst) {
		src = src[:len(dst)]
	}
	for i, x := range src {
		dst[i] = x
	}
	return len(src)
}