Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/comm Use getc instead of fgetc.



details:   https://anonhg.NetBSD.org/src/rev/782718b8ca10
branches:  trunk
changeset: 781420:782718b8ca10
user:      simonb <simonb%NetBSD.org@localhost>
date:      Wed Sep 05 04:01:23 2012 +0000

description:
Use getc instead of fgetc.

This is approximately five times faster for "comm -23 a b" where a and b
are identical 100MB files.

diffstat:

 usr.bin/comm/comm.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r d714f8bb4ac1 -r 782718b8ca10 usr.bin/comm/comm.c
--- a/usr.bin/comm/comm.c       Wed Sep 05 01:48:39 2012 +0000
+++ b/usr.bin/comm/comm.c       Wed Sep 05 04:01:23 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: comm.c,v 1.19 2011/08/30 21:36:38 joerg Exp $  */
+/*     $NetBSD: comm.c,v 1.20 2012/09/05 04:01:23 simonb Exp $ */
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)comm.c     8.4 (Berkeley) 5/4/95";
 #endif
-__RCSID("$NetBSD: comm.c,v 1.19 2011/08/30 21:36:38 joerg Exp $");
+__RCSID("$NetBSD: comm.c,v 1.20 2012/09/05 04:01:23 simonb Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -197,7 +197,7 @@
        size_t i = 0;
        int c;
 
-       while ((c = fgetc(fp)) != '\n' && c != EOF) {
+       while ((c = getc(fp)) != '\n' && c != EOF) {
                buf[i++] = c;
 
                if (i >= MAXLINELEN)



Home | Main Index | Thread Index | Old Index