From 4bd844b22f15ab1d73914a7210622a87b32a40df Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Tue, 26 Jul 2011 15:56:48 +0100 Subject: Convert O(N*M) to O(M*log_2(N)) --- src/rabbit_backing_queue_qc.erl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/rabbit_backing_queue_qc.erl b/src/rabbit_backing_queue_qc.erl index e20bba07..93e8efad 100644 --- a/src/rabbit_backing_queue_qc.erl +++ b/src/rabbit_backing_queue_qc.erl @@ -234,9 +234,7 @@ next_state(S, Res, {call, ?BQMOD, ack, [AcksArg, _BQ]}) -> #state{acks = AcksState} = S, BQ1 = {call, erlang, element, [2, Res]}, S#state{bqstate = BQ1, - acks = orddict:filter(fun (AckTag, _) -> - not lists:member(AckTag, AcksArg) - end, AcksState)}; + acks = lists:foldl(fun orddict:erase/2, AcksState, AcksArg)}; next_state(S, Res, {call, ?BQMOD, requeue, [AcksArg, _F, _V]}) -> #state{len = Len, messages = Messages, acks = AcksState} = S, @@ -246,9 +244,7 @@ next_state(S, Res, {call, ?BQMOD, requeue, [AcksArg, _F, _V]}) -> S#state{bqstate = BQ1, len = Len + length(RequeueMsgs), messages = queue:join(Messages, queue:from_list(RequeueMsgs)), - acks = orddict:filter(fun (AckTag, _) -> - not lists:member(AckTag, AcksArg) - end, AcksState)}; + acks = lists:foldl(fun orddict:erase/2, AcksState, AcksArg)}; next_state(S, BQ, {call, ?BQMOD, set_ram_duration_target, _Args}) -> S#state{bqstate = BQ}; -- cgit v1.2.1