diff options
author | Damien George <damien.p.george@gmail.com> | 2018-06-13 11:54:44 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-06-18 12:35:56 +1000 |
commit | 6abede2ca9e221b6aefcaccbda0c89e367507df1 (patch) | |
tree | 86f1097930f15027bf294510d221da002f320798 /tests/unix/extra_coverage.py | |
parent | 31cf49c672f6e141df2178e2ab0b6560244ea2e6 (diff) |
py/stream: Introduce and use efficient mp_get_stream to access stream_p.
The existing mp_get_stream_raise() helper does explicit checks that the
input object is a real pointer object, has a non-NULL stream protocol, and
has the desired stream C method (read/write/ioctl). In most cases it is
not necessary to do these checks because it is guaranteed that the input
object has the stream protocol and desired C methods. For example, native
objects that use the stream wrappers (eg mp_stream_readinto_obj) in their
locals dict always have the stream protocol (or else they shouldn't have
these wrappers in their locals dict).
This patch introduces an efficient mp_get_stream() which doesn't do any
checks and just extracts the stream protocol struct. This should be used
in all cases where the argument object is known to be a stream. The
existing mp_get_stream_raise() should be used primarily to verify that an
object does have the correct stream protocol methods.
All uses of mp_get_stream_raise() in py/stream.c have been converted to use
mp_get_stream() because the argument is guaranteed to be a proper stream
object.
This patch improves efficiency of stream operations and reduces code size.
Diffstat (limited to 'tests/unix/extra_coverage.py')
0 files changed, 0 insertions, 0 deletions