From 4aeb38abc1d9162b98a3ba4346ebdabad8532da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 6 May 2011 11:58:03 +0200 Subject: io.c: Make io_list_vec_len() less general io_list_vec_len() is slightly more general than it needs to be. Specifically: * The only caller always passes ERL_SMALL_IO_BIN_LIMIT as the value for the bin_limit parameter, so the bin_limit parameter can be eliminated. * The only caller never passes any NULL pointers, so there is no need test the pointers before writing through them. --- erts/emulator/beam/io.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'erts/emulator/beam/io.c') diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c index f619c6f88b..3610a06c0c 100644 --- a/erts/emulator/beam/io.c +++ b/erts/emulator/beam/io.c @@ -82,6 +82,9 @@ static void driver_monitor_unlock_pdl(Port *p); #define DRV_MONITOR_UNLOCK_PDL(Port) /* nothing */ #endif +#define ERL_SMALL_IO_BIN_LIMIT (4*ERL_ONHEAP_BIN_LIMIT) +#define SMALL_WRITE_VEC 16 + static ERTS_INLINE ErlIOQueue* drvport2ioq(ErlDrvPort drvport) { @@ -960,7 +963,7 @@ do { \ b_size += _size; \ in_clist = 0; \ v_size++; \ - if (_size >= bin_limit) { \ + if (_size >= ERL_SMALL_IO_BIN_LIMIT) { \ p_in_clist = 0; \ p_v_size++; \ } else { \ @@ -997,7 +1000,6 @@ do { \ static int io_list_vec_len(Eterm obj, int* vsize, int* csize, - int bin_limit, /* small binaries limit */ int * pvsize, int * pcsize) { DECLARE_ESTACK(s); @@ -1062,14 +1064,10 @@ io_list_vec_len(Eterm obj, int* vsize, int* csize, } DESTROY_ESTACK(s); - if (vsize != NULL) - *vsize = v_size; - if (csize != NULL) - *csize = c_size; - if (pvsize != NULL) - *pvsize = p_v_size; - if (pcsize != NULL) - *pcsize = p_c_size; + *vsize = v_size; + *csize = c_size; + *pvsize = p_v_size; + *pcsize = p_c_size; return c_size + b_size; L_type_error: @@ -1077,10 +1075,6 @@ io_list_vec_len(Eterm obj, int* vsize, int* csize, return -1; } -#define ERL_SMALL_IO_BIN_LIMIT (4*ERL_ONHEAP_BIN_LIMIT) -#define SMALL_WRITE_VEC 16 - - /* write data to a port */ int erts_write_to_port(Eterm caller_id, Port *p, Eterm list) { @@ -1107,7 +1101,6 @@ int erts_write_to_port(Eterm caller_id, Port *p, Eterm list) ErlIOVec ev; if ((size = io_list_vec_len(list, &vsize, &csize, - ERL_SMALL_IO_BIN_LIMIT, &pvsize, &pcsize)) < 0) { goto bad_value; } -- cgit v1.2.3