diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-01-10 16:06:02 +0000 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-01-10 16:06:02 +0000 |
| commit | 27e4b5bdded5f3ec43f9599c9798afac9b3e01ff (patch) | |
| tree | 4068b4c2e78d9710381c946183e88eb20fabe7ac | |
| parent | 1be3c923ca50061000a7673c7970fb09f6b6fcc0 (diff) | |
| download | rabbitmq-server-git-27e4b5bdded5f3ec43f9599c9798afac9b3e01ff.tar.gz | |
remove unneeded logic
| -rw-r--r-- | src/rabbit_channel.erl | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 52836e4037..4b166e28ff 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -1235,8 +1235,12 @@ internal_flush_confirms(State, []) -> State; internal_flush_confirms(State = #ch{writer_pid = WriterPid, unconfirmed = UC}, Cs) -> - CutOff = find_cutoff(UC, gb_sets:from_list(Cs)), - {Ms, Ss} = lists:splitwith(fun(X) -> X < CutOff end, lists:usort(Cs)), + SCs = lists:usort(Cs), + CutOff = case gb_sets:is_empty(UC) of + true -> lists:last(SCs) + 1; + false -> gb_sets:smallest(UC) + end, + {Ms, Ss} = lists:splitwith(fun(X) -> X < CutOff end, SCs), case Ms of [] -> ok; _ -> ok = rabbit_writer:send_command( @@ -1251,23 +1255,6 @@ internal_flush_confirms(State = #ch{writer_pid = WriterPid, end, ok, Ss), State. -%% Find the smallest element in SetA, not in SetB. -find_cutoff(SetA, SetB) -> - ItA = gb_sets:iterator(SetA), - case gb_sets:next(ItA) of - none -> -1; - {Element, ItA1} -> find_cutoff(Element, ItA, SetB) - end. - -find_cutoff(Element, ItA, SetB) -> - case gb_sets:is_element(Element, SetB) of - false -> Element; - true -> case gb_sets:next(ItA) of - {Element1, ItA1} -> find_cutoff(Element1, ItA1, SetB); - none -> Element + 1 - end - end. - terminate(_State) -> pg_local:leave(rabbit_channels, self()), rabbit_event:notify(channel_closed, [{pid, self()}]). |
