Remove unnecessary branch. Also, assertion of q3's emptiness is unnecessary as the rest of the code works perfectly well even if q3 isn't empty

This commit is contained in:
Matthew Sackman 2010-10-22 12:53:46 +01:00
parent 226d9285b9
commit bbae6be610
1 changed files with 32 additions and 37 deletions

View File

@ -1298,10 +1298,6 @@ maybe_deltas_to_betas(State = #vqstate {
q3 = Q3,
index_state = IndexState,
transient_threshold = TransientThreshold }) ->
case bpqueue:is_empty(Q3) of
false ->
State;
true ->
#delta { start_seq_id = DeltaSeqId,
count = DeltaCount,
end_seq_id = DeltaSeqIdEnd } = Delta,
@ -1310,13 +1306,13 @@ maybe_deltas_to_betas(State = #vqstate {
DeltaSeqIdEnd]),
{List, IndexState1} =
rabbit_queue_index:read(DeltaSeqId, DeltaSeqId1, IndexState),
{Q3a, IndexState2} = betas_from_index_entries(
List, TransientThreshold, IndexState1),
{Q3a, IndexState2} =
betas_from_index_entries(List, TransientThreshold, IndexState1),
State1 = State #vqstate { index_state = IndexState2 },
case bpqueue:len(Q3a) of
0 ->
%% we ignored every message in the segment due to
%% it being transient and below the threshold
%% we ignored every message in the segment due to it being
%% transient and below the threshold
maybe_deltas_to_betas(
State1 #vqstate {
delta = Delta #delta { start_seq_id = DeltaSeqId1 }});
@ -1324,8 +1320,8 @@ maybe_deltas_to_betas(State = #vqstate {
Q3b = bpqueue:join(Q3, Q3a),
case DeltaCount - Q3aLen of
0 ->
%% delta is now empty, but it wasn't
%% before, so can now join q2 onto q3
%% delta is now empty, but it wasn't before, so
%% can now join q2 onto q3
State1 #vqstate { q2 = bpqueue:new(),
delta = ?BLANK_DELTA,
q3 = bpqueue:join(Q3b, Q2) };
@ -1336,7 +1332,6 @@ maybe_deltas_to_betas(State = #vqstate {
State1 #vqstate { delta = Delta1,
q3 = Q3b }
end
end
end.
push_alphas_to_betas(Quota, State) ->