Especially with large inputs the change improves performance
considerably.
old> time more /boot/vmlinuz >/dev/null
real 0m0.224s
new> more /boot/vmlinuz >/dev/null
real 0m0.009s
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
void copy_file(register FILE *f)
{
- register int c;
+ char buf[BUFSIZ];
+ size_t sz;
- while ((c = getc(f)) != EOF)
- putchar(c);
+ while ((sz = fread(&buf, sizeof(char), sizeof(buf), f)) > 0)
+ fwrite(&buf, sizeof(char), sz, stdout);
}
#define ringbell() putcerr('\007')