Page MenuHomeFreeBSD

D30548.id90286.diff
No OneTemporary

D30548.id90286.diff

diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -99,6 +99,35 @@
fp->_r = 0;
total = resid;
p = buf;
+
+ /*
+ * If we're unbuffered we know that the buffer in fp is empty so
+ * we can read directly into buf. This is much faster than a
+ * series of one byte reads into fp->_nbuf.
+ */
+ if ((fp->_flags & __SNBF) != 0 && buf != NULL) {
+ while (resid > 0) {
+ /* set up the buffer */
+ fp->_bf._base = fp->_p = p;
+ fp->_bf._size = resid;
+
+ if (__srefill(fp)) {
+ /* no more input: return partial result */
+ count = (total - resid) / size;
+ break;
+ }
+ p += fp->_r;
+ resid -= fp->_r;
+ }
+
+ /* restore the old buffer (see __smakebuf) */
+ fp->_bf._base = fp->_p = fp->_nbuf;
+ fp->_bf._size = 1;
+ fp->_r = 0;
+
+ return (count);
+ }
+
while (resid > (r = fp->_r)) {
(void)memcpy((void *)p, (void *)fp->_p, (size_t)r);
fp->_p += r;

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 15, 11:54 AM (2 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29715364
Default Alt Text
D30548.id90286.diff (964 B)

Event Timeline