summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-21 00:43:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-21 00:43:07 +0000
commitf623979f65d43a109054ada8e8f271c3bfb6a747 (patch)
treeab0cb911b69c607cdf7136e7bc746ae12c6cd283 /io.c
parent9a836831905757698a81a7b2d1713106217572d7 (diff)
* io.c (IO_[CRW]BUF_CAPA_MIN): replaced magic numbers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/io.c b/io.c
index 60afd6c3c7..b077c29c90 100644
--- a/io.c
+++ b/io.c
@@ -109,6 +109,10 @@ extern void Init_File(void);
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
+#define IO_RBUF_CAPA_MIN 16384
+#define IO_CBUF_CAPA_MIN 16384
+#define IO_WBUF_CAPA_MIN 8192
+
VALUE rb_cIO;
VALUE rb_eEOFError;
VALUE rb_eIOError;
@@ -338,10 +342,10 @@ io_ungetbyte(VALUE str, rb_io_t *fptr)
if (len > INT_MAX)
rb_raise(rb_eIOError, "ungetbyte failed");
#endif
- if (len > 8192)
+ if (len > IO_RBUF_CAPA_MIN)
fptr->rbuf_capa = (int)len;
else
- fptr->rbuf_capa = 8192;
+ fptr->rbuf_capa = IO_RBUF_CAPA_MIN;
fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
}
if (fptr->rbuf_capa < len + fptr->rbuf_len) {
@@ -799,7 +803,7 @@ io_binwrite(VALUE str, rb_io_t *fptr, int nosync)
if (fptr->wbuf == NULL && !(!nosync && (fptr->mode & FMODE_SYNC))) {
fptr->wbuf_off = 0;
fptr->wbuf_len = 0;
- fptr->wbuf_capa = 8192;
+ fptr->wbuf_capa = IO_WBUF_CAPA_MIN;
fptr->wbuf = ALLOC_N(char, fptr->wbuf_capa);
fptr->write_lock = rb_mutex_new();
}
@@ -1171,7 +1175,7 @@ io_fillbuf(rb_io_t *fptr)
if (fptr->rbuf == NULL) {
fptr->rbuf_off = 0;
fptr->rbuf_len = 0;
- fptr->rbuf_capa = 8192;
+ fptr->rbuf_capa = IO_RBUF_CAPA_MIN;
fptr->rbuf = ALLOC_N(char, fptr->rbuf_capa);
}
if (fptr->rbuf_len == 0) {
@@ -1426,7 +1430,7 @@ rb_io_inspect(VALUE obj)
{
rb_io_t *fptr;
const char *cname;
- char fd_desc[256];
+ char fd_desc[4+sizeof(int)*3];
const char *path;
const char *st = "";
@@ -1587,7 +1591,8 @@ make_readconv(rb_io_t *fptr, int size)
rb_exc_raise(rb_econv_open_exc(sname, dname, ecflags));
fptr->cbuf_off = 0;
fptr->cbuf_len = 0;
- fptr->cbuf_capa = size < 1024 ? 1024 : size;
+ if (size < IO_CBUF_CAPA_MIN) size = IO_CBUF_CAPA_MIN;
+ fptr->cbuf_capa = size;
fptr->cbuf = ALLOC_N(char, fptr->cbuf_capa);
}
}