aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/pack
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-08-30 15:46:12 +0400
committerDmitriy Vyukov <dvyukov@google.com>2013-08-30 15:46:12 +0400
commit79dca0327ed8a7f65f3680e72cb1dcf4caaed457 (patch)
tree450091598b2acded10db1c416e9190de5949ebec /src/cmd/pack
parent2df3d800378fda123395609189fabdd403634d80 (diff)
downloadgo-79dca0327ed8a7f65f3680e72cb1dcf4caaed457.tar.gz
go-79dca0327ed8a7f65f3680e72cb1dcf4caaed457.zip
libbio, all cmd: consistently use BGETC/BPUTC instead of Bgetc/Bputc
Also introduce BGET2/4, BPUT2/4 as they are widely used. Slightly improve BGETC/BPUTC implementation. This gives ~5% CPU time improvement on go install -a -p1 std. Before: real user sys 0m23.561s 0m16.625s 0m5.848s 0m23.766s 0m16.624s 0m5.846s 0m23.742s 0m16.621s 0m5.868s after: 0m22.999s 0m15.841s 0m5.889s 0m22.845s 0m15.808s 0m5.850s 0m22.889s 0m15.832s 0m5.848s R=golang-dev, r CC=golang-dev https://golang.org/cl/12745047
Diffstat (limited to 'src/cmd/pack')
-rw-r--r--src/cmd/pack/ar.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/cmd/pack/ar.c b/src/cmd/pack/ar.c
index 284eff5ca5..aff5f37eb9 100644
--- a/src/cmd/pack/ar.c
+++ b/src/cmd/pack/ar.c
@@ -700,7 +700,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
// the ! comes immediately. Catch that so we can avoid
// the call to scanpkg below, since scanpkg assumes that the
// Go metadata is present.
- if(Bgetc(b) == '!')
+ if(BGETC(b) == '!')
goobject = 0;
Bseek(b, offset1, 0);
@@ -807,13 +807,13 @@ scanpkg(Biobuf *b, long size)
* scan until $$
*/
for (n=0; n<size; ) {
- c = Bgetc(b);
+ c = BGETC(b);
if(c == Beof)
break;
n++;
if(c != '$')
continue;
- c = Bgetc(b);
+ c = BGETC(b);
if(c == Beof)
break;
n++;
@@ -828,7 +828,7 @@ scanpkg(Biobuf *b, long size)
foundstart:
/* found $$; skip rest of line */
- while((c = Bgetc(b)) != '\n')
+ while((c = BGETC(b)) != '\n')
if(c == Beof)
goto bad;
@@ -1263,7 +1263,7 @@ rl(int fd)
wrsym(&b, len, aend->sym);
if(symdefsize&0x01)
- Bputc(&b, 0);
+ BPUTC(&b, 0);
if (gflag) {
len = pkgdefsize;
@@ -1283,7 +1283,7 @@ rl(int fd)
if (Bwrite(&b, pkgdefdata, pkgdefsize) != pkgdefsize)
wrerr();
if(len&0x01)
- Bputc(&b, 0);
+ BPUTC(&b, 0);
}
Bterm(&b);
}
@@ -1297,12 +1297,9 @@ wrsym(Biobuf *bp, long offset, Arsymref *as)
int off;
while(as) {
- Bputc(bp, as->type);
+ BPUTC(bp, as->type);
off = as->offset+offset;
- Bputc(bp, off);
- Bputc(bp, off>>8);
- Bputc(bp, off>>16);
- Bputc(bp, off>>24);
+ BPUTLE4(bp, off);
if (Bwrite(bp, as->name, as->len+1) != as->len+1)
wrerr();
as = as->next;
@@ -1454,7 +1451,7 @@ select(int *ap, long mode)
n = *ap++;
while(--n>=0 && (mode&*ap++)==0)
ap++;
- Bputc(&bout, *ap);
+ BPUTC(&bout, *ap);
}
/*
@@ -1506,7 +1503,7 @@ arread(Biobuf *b, Armember *bp) /* read an image into a member buffer */
rderr();
}
if(bp->size&1)
- Bgetc(b);
+ BGETC(b);
}
/*
@@ -1734,6 +1731,6 @@ arread_cutprefix(Biobuf *b, Armember *bp)
strncpy(bp->hdr.fmag, ARFMAG, 2);
Bseek(b, end, 0);
if(Boffset(b)&1)
- Bgetc(b);
+ BGETC(b);
return 1;
}