only use writev for larger chunks in buffer_putflush

only use lseek if it saves a read in buffer_seek
master
leitner 4 years ago
parent 45f7a362e0
commit b67a1af443

@ -22,7 +22,7 @@ int buffer_putflush(buffer* b,const char* x,size_t len) {
if (!b->p) /* if the buffer is empty, just call buffer_stubborn directly */
return buffer_stubborn(b->op,b->fd,x,len,b);
#ifndef __MINGW32__
if (b->op==write) {
if (b->op==write && len>sizeof(struct iovec)*2) {
struct iovec v[2];
ssize_t w;
size_t cl=b->p+len;

@ -17,8 +17,9 @@ ssize_t buffer_seek(buffer* b,size_t len) {
len -= leftinbuf;
b->p = 0; // clear buffer
b->n = 0;
/* change position in underlying file */
if (b->fd != -1 &&
if (b->fd != -1 && len > b->a &&
lseek(b->fd, len, SEEK_CUR) != -1) return len;
// either we have no fd or input is not seekable
// call read repeatedly

Loading…
Cancel
Save