shithub: riscv

Download patch

ref: fff474d8639fd387aac437e0a84a06604000c3ba
parent: 1a40bdeb843042a66d913e8fbf15fad4bf3a5875
author: aiju <devnull@localhost>
date: Mon Jun 12 15:56:57 EDT 2017

xd: use new bio magic to make -u more efficient

--- a/sys/src/cmd/xd.c
+++ b/sys/src/cmd/xd.c
@@ -58,6 +58,13 @@
 Biobuf	bin;
 Biobuf	bout;
 
+int
+flushout(Biobufhdr *bp, void *v, long n)
+{
+	Bflush(&bout);
+	return read(bp->fid, v, n);
+}
+
 void
 main(int argc, char *argv[])
 {
@@ -206,6 +213,7 @@
 		bp = &bin;
 		Binit(bp, fd, OREAD);
 	}
+	if(flush) Biofn(bp, flushout);
 	Blethal(bp, nil);
 	if(title)
 		xprint("%s\n", name);
@@ -237,15 +245,11 @@
 			xprint(ap->afmt, addr);
 			(*ap->fn)(ap->fmt);
 			xprint("\n", 0);
-			if(flush)
-				Bflush(&bout);
 		}
 		addr += ndata;
 		if(ndata<16){
 			xprint(afmt[0][abase], addr);
 			xprint("\n", 0);
-			if(flush)
-				Bflush(&bout);
 			break;
 		}
 	}