# HG changeset patch # User Timo Sirainen # Date 1507627988 -10800 # Node ID 09164094f25414ef41de4260130e65b3bdfb370b # Parent be272aa6e87800f730d8f6cea032372a66ab88fc lib: istream-multiplex - Minor optimization There's no need to find channel when we already know it. This also helps static analyzers to understand that req_channel can't be NULL. diff -r be272aa6e878 -r 09164094f254 src/lib/istream-multiplex.c --- a/src/lib/istream-multiplex.c Tue Oct 10 12:52:15 2017 +0300 +++ b/src/lib/istream-multiplex.c Tue Oct 10 12:33:08 2017 +0300 @@ -63,9 +63,9 @@ } static ssize_t -i_stream_multiplex_read(struct multiplex_istream *mstream, uint8_t cid) +i_stream_multiplex_read(struct multiplex_istream *mstream, + struct multiplex_ichannel *req_channel) { - struct multiplex_ichannel *req_channel = get_channel(mstream, cid); const unsigned char *data; size_t len = 0, used, wanted, avail; ssize_t ret, got = 0; @@ -97,7 +97,7 @@ if (got == 0 && mstream->blocking) { /* can't return 0 with blocking istreams, so try again from the beginning. */ - return i_stream_multiplex_read(mstream, cid); + return i_stream_multiplex_read(mstream, req_channel); } break; } @@ -114,7 +114,7 @@ stream->pos -= channel->pending_pos; if (!alloc_ret) { i_stream_set_input_pending(&stream->istream, TRUE); - if (channel->cid != cid) + if (channel->cid != req_channel->cid) return 0; if (got > 0) break; @@ -124,7 +124,7 @@ used = I_MIN(wanted, avail); /* dump into buffer */ - if (channel->cid != cid) { + if (channel->cid != req_channel->cid) { i_assert(stream->pos + channel->pending_pos + used <= stream->buffer_size); memcpy(stream->w_buffer + stream->pos + channel->pending_pos, data, used); @@ -178,7 +178,7 @@ channel->pending_pos = 0; return ret; } - return i_stream_multiplex_read(channel->mstream, channel->cid); + return i_stream_multiplex_read(channel->mstream, channel); } static void