From 27e735fd1870e24595eadb02164b164a3bb81b98 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 5 Apr 2014 23:02:23 +0100 Subject: py: Replace stream_p with *stream_p in mp_obj_type_t. This is to reduce ROM usage. stream_p is used in file and socket types only (at the moment), so seems a good idea to make the protocol functions a pointer instead of the actual structure. It saves 308 bytes of ROM in the stmhal/ port, 928 in unix/. --- unix/modsocket.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'unix/modsocket.c') diff --git a/unix/modsocket.c b/unix/modsocket.c index 6bdbc889d..62f10300f 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -240,6 +240,11 @@ STATIC const mp_map_elem_t microsocket_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(microsocket_locals_dict, microsocket_locals_dict_table); +STATIC const mp_stream_p_t microsocket_stream_p = { + .read = socket_read, + .write = socket_write, +}; + STATIC const mp_obj_type_t microsocket_type = { { &mp_type_type }, .name = MP_QSTR_socket, @@ -247,10 +252,7 @@ STATIC const mp_obj_type_t microsocket_type = { .make_new = socket_make_new, .getiter = NULL, .iternext = NULL, - .stream_p = { - .read = socket_read, - .write = socket_write, - }, + .stream_p = µsocket_stream_p, .locals_dict = (mp_obj_t)µsocket_locals_dict, }; -- cgit v1.2.3