plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 29fba8562cd8585a613046b509347c905642be16
parent 5e83be0dbf9667f7d11a167f9eacc31837ed4c7d
Author: Russ Cox <rsc@swtch.com>
Date:   Tue, 28 Jun 2011 18:58:44 -0400

primes: faster output

R=rsc
http://codereview.appspot.com/4664053

Diffstat:
Msrc/cmd/primes.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/cmd/primes.c b/src/cmd/primes.c @@ -1,5 +1,6 @@ #include <u.h> #include <libc.h> +#include <bio.h> #define ptsiz (sizeof(pt)/sizeof(pt[0])) #define whsiz (sizeof(wheel)/sizeof(wheel[0])) @@ -32,6 +33,7 @@ uchar bittab[] = void mark(double nn, long k); void ouch(void); +Biobuf bout; void main(int argc, char *argp[]) @@ -39,6 +41,8 @@ main(int argc, char *argp[]) int i; double k, temp, v, limit, nn; + Binit(&bout, 1, OWRITE); + if(argc <= 1) { fprint(2, "usage: primes starting [ending]\n"); exits("usage"); @@ -101,7 +105,7 @@ main(int argc, char *argp[]) temp = nn + i; if(temp > limit) exits(0); - print("%.0f\n", temp); + Bprint(&bout, "%lld\n", (long long)temp); if(limit >= big) exits(0); }