tprimes: faster output - plan9port - [fork] Plan 9 from user space
(HTM) git clone git://src.adamsgaard.dk/plan9port
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 29fba8562cd8585a613046b509347c905642be16
(DIR) parent 5e83be0dbf9667f7d11a167f9eacc31837ed4c7d
(HTM) 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:
M src/cmd/primes.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/src/cmd/primes.c b/src/cmd/primes.c
t@@ -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]))
t@@ -32,6 +33,7 @@ uchar bittab[] =
void mark(double nn, long k);
void ouch(void);
+Biobuf bout;
void
main(int argc, char *argp[])
t@@ -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");
t@@ -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);
}