mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: rename reflect.ArrayCopy to be reflect.Copy.
R=r CC=golang-dev https://golang.org/cl/3601041
This commit is contained in:
parent
7ec69c179d
commit
73fd298901
5 changed files with 8 additions and 8 deletions
|
|
@ -591,7 +591,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
|
||||||
sliceValue := v.(*reflect.SliceValue)
|
sliceValue := v.(*reflect.SliceValue)
|
||||||
sliceValue.Set(reflect.MakeSlice(sliceValue.Type().(*reflect.SliceType), len(newSlice), len(newSlice)))
|
sliceValue.Set(reflect.MakeSlice(sliceValue.Type().(*reflect.SliceType), len(newSlice), len(newSlice)))
|
||||||
if err1 == nil {
|
if err1 == nil {
|
||||||
reflect.ArrayCopy(sliceValue, reflect.NewValue(newSlice).(reflect.ArrayOrSliceValue))
|
reflect.Copy(sliceValue, reflect.NewValue(newSlice).(reflect.ArrayOrSliceValue))
|
||||||
}
|
}
|
||||||
err = err1
|
err = err1
|
||||||
return
|
return
|
||||||
|
|
@ -683,7 +683,7 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
|
||||||
sliceType := fieldType.(*reflect.SliceType)
|
sliceType := fieldType.(*reflect.SliceType)
|
||||||
if sliceType.Elem().Kind() == reflect.Uint8 {
|
if sliceType.Elem().Kind() == reflect.Uint8 {
|
||||||
val.Set(reflect.MakeSlice(sliceType, len(innerBytes), len(innerBytes)))
|
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
|
return
|
||||||
}
|
}
|
||||||
newSlice, err1 := parseSequenceOf(innerBytes, sliceType, sliceType.Elem())
|
newSlice, err1 := parseSequenceOf(innerBytes, sliceType, sliceType.Elem())
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ func (d *decodeState) array(v reflect.Value) {
|
||||||
newcap = 4
|
newcap = 4
|
||||||
}
|
}
|
||||||
newv := reflect.MakeSlice(sv.Type().(*reflect.SliceType), sv.Len(), newcap)
|
newv := reflect.MakeSlice(sv.Type().(*reflect.SliceType), sv.Len(), newcap)
|
||||||
reflect.ArrayCopy(newv, sv)
|
reflect.Copy(newv, sv)
|
||||||
sv.Set(newv)
|
sv.Set(newv)
|
||||||
}
|
}
|
||||||
if i >= av.Len() && sv != nil {
|
if i >= av.Len() && sv != nil {
|
||||||
|
|
|
||||||
|
|
@ -513,7 +513,7 @@ func TestCopyArray(t *testing.T) {
|
||||||
ab := vb.(*PtrValue).Elem().(*SliceValue)
|
ab := vb.(*PtrValue).Elem().(*SliceValue)
|
||||||
for tocopy := 1; tocopy <= 7; tocopy++ {
|
for tocopy := 1; tocopy <= 7; tocopy++ {
|
||||||
aa.SetLen(tocopy)
|
aa.SetLen(tocopy)
|
||||||
ArrayCopy(ab, aa)
|
Copy(ab, aa)
|
||||||
aa.SetLen(8)
|
aa.SetLen(8)
|
||||||
for i := 0; i < tocopy; i++ {
|
for i := 0; i < tocopy; i++ {
|
||||||
if a[i] != b[i] {
|
if a[i] != b[i] {
|
||||||
|
|
|
||||||
|
|
@ -400,11 +400,11 @@ type ArrayOrSliceValue interface {
|
||||||
addr() addr
|
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.
|
// dst has been filled or src has been exhausted.
|
||||||
// It returns the number of elements copied.
|
// It returns the number of elements copied.
|
||||||
// The arrays dst and src must have the same element type.
|
// 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
|
// TODO: This will have to move into the runtime
|
||||||
// once the real gc goes in.
|
// once the real gc goes in.
|
||||||
de := dst.Type().(ArrayOrSliceType).Elem()
|
de := dst.Type().(ArrayOrSliceType).Elem()
|
||||||
|
|
@ -439,7 +439,7 @@ func (v *ArrayValue) Set(x *ArrayValue) {
|
||||||
panic(cannotSet)
|
panic(cannotSet)
|
||||||
}
|
}
|
||||||
typesMustMatch(v.typ, x.typ)
|
typesMustMatch(v.typ, x.typ)
|
||||||
ArrayCopy(v, x)
|
Copy(v, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sets v to the value x.
|
// Set sets v to the value x.
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ func (p *Parser) unmarshal(val reflect.Value, start *StartElement) os.Error {
|
||||||
ncap = 4
|
ncap = 4
|
||||||
}
|
}
|
||||||
new := reflect.MakeSlice(typ, n, ncap)
|
new := reflect.MakeSlice(typ, n, ncap)
|
||||||
reflect.ArrayCopy(new, v)
|
reflect.Copy(new, v)
|
||||||
v.Set(new)
|
v.Set(new)
|
||||||
}
|
}
|
||||||
v.SetLen(n + 1)
|
v.SetLen(n + 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue