Hi, On Fri, 16 May 2008, Avery Pennarun wrote:Well, my question was more about fgetc() vs fgets(). If you feel like it, you might benchmark this patch: -- snipsnap -- diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c index 021dc16..5d8defd 100644 --- a/builtin-mailsplit.c +++ b/builtin-mailsplit.c @@ -45,13 +45,32 @@ static int is_from_line(const char *line, int len) /* Could be as small as 64, enough to hold a Unix "From " line. */ static char buf[4096]; +/* + * This is an ugly hack to avoid fgetc(), which is slow, as it is locking. + * The argument "in" must be the same for all calls to this function! + */ +static int fast_fgetc(FILE *in) +{ + static char buf[4096]; + static int offset = 0, len = 0; + + if (offset >= len) { + len = fread(buf, 1, sizeof(buf), in); + offset = 0; + if (!len && feof(in)) + return EOF; + } + + return buf[offset++]; +} + /* We cannot use fgets() because our lines can contain NULs */ int read_line_with_nul(char *buf, int size, FILE *in) { int len = 0, c; for (;;) { - c = fgetc(in); + c = fast_fgetc(in); buf[len++] = c; if (c == EOF || c == '\n' || len + 1 >= size) break; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| Alan Cox | [PATCH 01/76] drivers/serial/crisv10.c: add missing put_tty_driver |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Adrian Bunk | Re: Linux 2.6.21 |
| David Miller | Slow DOWN, please!!! |
git: | |
| Jon Smirl | Re: VCS comparison table |
| Junio C Hamano | [RFD] On deprecating "git-foo" for builtins |
| Eric Wong | [PATCH] archimport improvements |
| Johannes Schindelin | Re: [FAQ?] Rationale for git's way to manage the index |
| Richard Stallman | Real men don't attack straw men |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Leon Dippenaar | New tcp stack attack |
| Henning Brauer | Re: About Xen: maybe a reiterative question but .. |
| David Miller | [GIT]: Networking |
| Mark Lord | Re: 2.6.25-rc8: FTP transfer errors |
| Alexey Dobriyan | [PATCH 01/33] nf_conntrack_sip: de-static helper pointers |
| Evgeniy Polyakov | Re: [BUG] New Kernel Bugs |
