Mercurial > dovecot > core-2.2
changeset 22601:09164094f254
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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 10 Oct 2017 12:33:08 +0300 |
parents | be272aa6e878 |
children | f36d7c6d7533 |
files | src/lib/istream-multiplex.c |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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