Commit f0c97195 authored by Christopher Wedgwood's avatar Christopher Wedgwood Committed by Russ Cox

Minimise bitrot: bytes.Copy -> copy

(compile tested only)

R=r, rsc
https://golang.org/cl/161069
parent cd9d72ba
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
package av package av
import ( import (
"bytes";
"exp/draw"; "exp/draw";
"exp/nacl/srpc"; "exp/nacl/srpc";
"log"; "log";
...@@ -158,7 +157,7 @@ func videoPollEvent(ev []byte) (err os.Error) { ...@@ -158,7 +157,7 @@ func videoPollEvent(ev []byte) (err os.Error) {
if r == bridge.share.eq.wi { if r == bridge.share.eq.wi {
return noEvents return noEvents
} }
bytes.Copy(ev, &bridge.share.eq.event[r]); copy(ev, &bridge.share.eq.event[r]);
bridge.share.eq.ri = (r + 1) % eqsize; bridge.share.eq.ri = (r + 1) % eqsize;
return nil; return nil;
} }
......
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
package av package av
import ( import (
"bytes"; "encoding/binary";
"debug/binary";
"exp/draw"; "exp/draw";
"log"; "log";
"os"; "os";
...@@ -383,7 +382,7 @@ func (r *reader) Read(p []byte) (n int, err os.Error) { ...@@ -383,7 +382,7 @@ func (r *reader) Read(p []byte) (n int, err os.Error) {
if len(b) == 0 && len(p) > 0 { if len(b) == 0 && len(p) > 0 {
return 0, os.EOF return 0, os.EOF
} }
n = bytes.Copy(p, b); n = copy(p, b);
*r = b[n:]; *r = b[n:];
return; return;
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
package srpc package srpc
import ( import (
"bytes";
"math"; "math";
"os"; "os";
"strconv"; "strconv";
...@@ -121,7 +120,7 @@ func (r *msgReceiver) recv() (*msg, os.Error) { ...@@ -121,7 +120,7 @@ func (r *msgReceiver) recv() (*msg, os.Error) {
// returned the total byte count as n. // returned the total byte count as n.
m := new(msg); m := new(msg);
m.rdata = make([]byte, n); m.rdata = make([]byte, n);
bytes.Copy(m.rdata, &r.data); copy(m.rdata, &r.data);
// Make a copy of the desc too. // Make a copy of the desc too.
// The system call *did* update r.hdr.ndesc. // The system call *did* update r.hdr.ndesc.
...@@ -219,7 +218,7 @@ func (m *msg) grow(n int) []byte { ...@@ -219,7 +218,7 @@ func (m *msg) grow(n int) []byte {
i := len(m.wdata); i := len(m.wdata);
if i+n > cap(m.wdata) { if i+n > cap(m.wdata) {
a := make([]byte, i, (i+n)*2); a := make([]byte, i, (i+n)*2);
bytes.Copy(a, m.wdata); copy(a, m.wdata);
m.wdata = a; m.wdata = a;
} }
m.wdata = m.wdata[0 : i+n]; m.wdata = m.wdata[0 : i+n];
...@@ -250,7 +249,7 @@ func (m *msg) wuint64(x uint64) { ...@@ -250,7 +249,7 @@ func (m *msg) wuint64(x uint64) {
b[7] = byte(hi >> 24); b[7] = byte(hi >> 24);
} }
func (m *msg) wbytes(p []byte) { bytes.Copy(m.grow(len(p)), p) } func (m *msg) wbytes(p []byte) { copy(m.grow(len(p)), p) }
func (m *msg) wstring(s string) { func (m *msg) wstring(s string) {
b := m.grow(len(s)); b := m.grow(len(s));
......
...@@ -385,17 +385,6 @@ func Sendto(fd int, p []byte, flags int, to Sockaddr) (errno int) { ...@@ -385,17 +385,6 @@ func Sendto(fd int, p []byte, flags int, to Sockaddr) (errno int) {
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (errno int) //sys ptrace(request int, pid int, addr uintptr, data uintptr) (errno int)
// See bytes.Copy.
func bytesCopy(dst, src []byte) int {
if len(src) > len(dst) {
src = src[0:len(dst)]
}
for i, x := range src {
dst[i] = x
}
return len(src);
}
func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno int) { func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno int) {
// The peek requests are machine-size oriented, so we wrap it // The peek requests are machine-size oriented, so we wrap it
// to retrieve arbitrary-length data. // to retrieve arbitrary-length data.
...@@ -416,7 +405,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in ...@@ -416,7 +405,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in
if errno != 0 { if errno != 0 {
return 0, errno return 0, errno
} }
n += bytesCopy(out, buf[addr%sizeofPtr:]); n += copy(out, buf[addr%sizeofPtr:]);
out = out[n:]; out = out[n:];
} }
...@@ -428,7 +417,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in ...@@ -428,7 +417,7 @@ func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, errno in
if errno != 0 { if errno != 0 {
return n, errno return n, errno
} }
copied := bytesCopy(out, &buf); copied := copy(out, &buf);
n += copied; n += copied;
out = out[copied:]; out = out[copied:];
} }
...@@ -456,7 +445,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c ...@@ -456,7 +445,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c
if errno != 0 { if errno != 0 {
return 0, errno return 0, errno
} }
n += bytesCopy(buf[addr%sizeofPtr:], data); n += copy(buf[addr%sizeofPtr:], data);
word := *((*uintptr)(unsafe.Pointer(&buf[0]))); word := *((*uintptr)(unsafe.Pointer(&buf[0])));
errno = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word); errno = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word);
if errno != 0 { if errno != 0 {
...@@ -483,7 +472,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c ...@@ -483,7 +472,7 @@ func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (c
if errno != 0 { if errno != 0 {
return n, errno return n, errno
} }
bytesCopy(&buf, data); copy(&buf, data);
word := *((*uintptr)(unsafe.Pointer(&buf[0]))); word := *((*uintptr)(unsafe.Pointer(&buf[0])));
errno = ptrace(pokeReq, pid, addr+uintptr(n), word); errno = ptrace(pokeReq, pid, addr+uintptr(n), word);
if errno != 0 { if errno != 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment