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

avoid pointer-to-slice operations in gobuild

R=r
DELTA=19  (3 added, 1 deleted, 15 changed)
OCL=30591
CL=30601
This commit is contained in:
Russ Cox 2009-06-22 14:24:32 -07:00
parent ee23998963
commit 2fcc8f2fb6
2 changed files with 15 additions and 13 deletions

View File

@ -60,31 +60,33 @@ type Info struct {
var verbose = flag.Bool("v", false, "verbose mode")
var writeMakefile = flag.Bool("m", false, "write Makefile to standard output")
func PushPkg(v *[]*Pkg, p *Pkg) {
func PushPkg(vp *[]*Pkg, p *Pkg) {
v := *vp;
n := len(v);
if n >= cap(v) {
m := 2*n + 10;
a := make([]*Pkg, n, m);
for i := range *v {
for i := range v {
a[i] = v[i];
}
*v = a;
v = a;
}
*v = v[0:n+1];
*vp = v[0:n+1];
v[n] = p;
}
func PushFile(v *[]*File, p *File) {
func PushFile(vp *[]*File, p *File) {
v := *vp;
n := len(v);
if n >= cap(v) {
m := 2*n + 10;
a := make([]*File, n, m);
for i := range *v {
for i := range v {
a[i] = v[i];
}
*v = a;
v = a;
}
*v = v[0:n+1];
*vp = v[0:n+1];
v[n] = p;
}

View File

@ -71,21 +71,21 @@ func init() {
}
}
func PushString(v *[]string, p string) {
func PushString(vp *[]string, p string) {
v := *vp;
n := len(v);
if n >= cap(v) {
m := 2*n + 10;
a := make([]string, n, m);
for i := range *v {
for i := range v {
a[i] = v[i];
}
*v = a;
v = a;
}
*v = v[0:n+1];
*vp = v[0:n+1];
v[n] = p;
}
func run(argv []string, flag int) (ok bool) {
argv0 := bin[argv[0]];
null, err := os.Open("/dev/null", os.O_RDWR, 0);