1
0
mirror of https://github.com/golang/go synced 2024-11-24 09:10:24 -07:00

reflect: rename reflect.ArrayCopy to be reflect.Copy.

R=r
CC=golang-dev
https://golang.org/cl/3601041
This commit is contained in:
Nigel Tao 2010-12-12 20:27:29 +11:00
parent 7ec69c179d
commit 73fd298901
5 changed files with 8 additions and 8 deletions

View File

@ -591,7 +591,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
sliceValue := v.(*reflect.SliceValue)
sliceValue.Set(reflect.MakeSlice(sliceValue.Type().(*reflect.SliceType), len(newSlice), len(newSlice)))
if err1 == nil {
reflect.ArrayCopy(sliceValue, reflect.NewValue(newSlice).(reflect.ArrayOrSliceValue))
reflect.Copy(sliceValue, reflect.NewValue(newSlice).(reflect.ArrayOrSliceValue))
}
err = err1
return
@ -683,7 +683,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
sliceType := fieldType.(*reflect.SliceType)
if sliceType.Elem().Kind() == reflect.Uint8 {
val.Set(reflect.MakeSlice(sliceType, len(innerBytes), len(innerBytes)))
reflect.ArrayCopy(val, reflect.NewValue(innerBytes).(reflect.ArrayOrSliceValue))
reflect.Copy(val, reflect.NewValue(innerBytes).(reflect.ArrayOrSliceValue))
return
}
newSlice, err1 := parseSequenceOf(innerBytes, sliceType, sliceType.Elem())

View File

@ -344,7 +344,7 @@ func (d *decodeState) array(v reflect.Value) {
newcap = 4
}
newv := reflect.MakeSlice(sv.Type().(*reflect.SliceType), sv.Len(), newcap)
reflect.ArrayCopy(newv, sv)
reflect.Copy(newv, sv)
sv.Set(newv)
}
if i >= av.Len() && sv != nil {

View File

@ -513,7 +513,7 @@ func TestCopyArray(t *testing.T) {
ab := vb.(*PtrValue).Elem().(*SliceValue)
for tocopy := 1; tocopy <= 7; tocopy++ {
aa.SetLen(tocopy)
ArrayCopy(ab, aa)
Copy(ab, aa)
aa.SetLen(8)
for i := 0; i < tocopy; i++ {
if a[i] != b[i] {

View File

@ -400,11 +400,11 @@ type ArrayOrSliceValue interface {
addr() addr
}
// ArrayCopy copies the contents of src into dst until either
// Copy copies the contents of src into dst until either
// dst has been filled or src has been exhausted.
// It returns the number of elements copied.
// The arrays dst and src must have the same element type.
func ArrayCopy(dst, src ArrayOrSliceValue) int {
func Copy(dst, src ArrayOrSliceValue) int {
// TODO: This will have to move into the runtime
// once the real gc goes in.
de := dst.Type().(ArrayOrSliceType).Elem()
@ -439,7 +439,7 @@ func (v *ArrayValue) Set(x *ArrayValue) {
panic(cannotSet)
}
typesMustMatch(v.typ, x.typ)
ArrayCopy(v, x)
Copy(v, x)
}
// Set sets v to the value x.

View File

@ -233,7 +233,7 @@ func (p *Parser) unmarshal(val reflect.Value, start *StartElement) os.Error {
ncap = 4
}
new := reflect.MakeSlice(typ, n, ncap)
reflect.ArrayCopy(new, v)
reflect.Copy(new, v)
v.Set(new)
}
v.SetLen(n + 1)