Browse Source

only use writev for larger chunks in buffer_putflush

only use lseek if it saves a read in buffer_seek
master
Felix von Leitner 9 months ago
parent
commit
c3366f8bbb
  1. 2
      buffer/buffer_putflush.c
  2. 3
      buffer/buffer_seek.c

2
buffer/buffer_putflush.c

@ -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;

3
buffer/buffer_seek.c

@ -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