diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-05 23:02:23 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-05 23:02:23 +0100 |
commit | 27e735fd1870e24595eadb02164b164a3bb81b98 (patch) | |
tree | 055a15886ec0e55f19d32533a827fa5d1586b6a6 /unix/file.c | |
parent | 17520224fad7a0c4a742f9b8a46e016c2ba3cc46 (diff) |
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/.
Diffstat (limited to 'unix/file.c')
-rw-r--r-- | unix/file.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/unix/file.c b/unix/file.c index 780e84718..2cc17dfd3 100644 --- a/unix/file.c +++ b/unix/file.c @@ -123,6 +123,11 @@ STATIC const mp_map_elem_t rawfile_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); +STATIC const mp_stream_p_t rawfile_stream_p = { + .read = fdfile_read, + .write = fdfile_write, +}; + STATIC const mp_obj_type_t rawfile_type = { { &mp_type_type }, .name = MP_QSTR_io_dot_FileIO, @@ -130,10 +135,7 @@ STATIC const mp_obj_type_t rawfile_type = { .make_new = fdfile_make_new, .getiter = mp_identity, .iternext = mp_stream_unbuffered_iter, - .stream_p = { - .read = fdfile_read, - .write = fdfile_write, - }, + .stream_p = &rawfile_stream_p, .locals_dict = (mp_obj_t)&rawfile_locals_dict, }; |