summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2011-10-27 13:20:32 +0100
committerEmile Joubert <emile@rabbitmq.com>2011-10-27 13:20:32 +0100
commit6ec2a3a38e435c5ff37c6318a8d3d16b01b97e35 (patch)
tree45bb40236beaf952e5df673ca11c6b92645e907c
parent13bc32fa5742635d772f70efdbbe9104450fe584 (diff)
downloadrabbitmq-server-6ec2a3a38e435c5ff37c6318a8d3d16b01b97e35.tar.gz
Reduce nesting of case statements
(Courtesy of Matthias)
-rw-r--r--src/rabbit_memory_monitor.erl27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/rabbit_memory_monitor.erl b/src/rabbit_memory_monitor.erl
index 9cfc1583..02f3158f 100644
--- a/src/rabbit_memory_monitor.erl
+++ b/src/rabbit_memory_monitor.erl
@@ -211,22 +211,19 @@ internal_update(State = #state { queue_durations = Durations,
queue_duration_sum = Sum,
queue_duration_count = Count }) ->
MemoryLimit = ?MEMORY_LIMIT_SCALING * vm_memory_monitor:get_memory_limit(),
+ MemoryRatio = case MemoryLimit > 0.0 of
+ true -> erlang:memory(total) / MemoryLimit;
+ false -> infinity
+ end,
DesiredDurationAvg1 =
- case MemoryLimit > 0.0 of
- true ->
- MemoryRatio = erlang:memory(total) / MemoryLimit,
- case MemoryRatio < ?LIMIT_THRESHOLD orelse Count == 0 of
- true ->
- infinity;
- false ->
- Sum1 = case MemoryRatio < ?SUM_INC_THRESHOLD of
- true -> Sum + ?SUM_INC_AMOUNT;
- false -> Sum
- end,
- (Sum1 / Count) / MemoryRatio
- end;
- false ->
- 0.0
+ if MemoryRatio =:= infinity ->
+ 0.0;
+ MemoryRatio < ?LIMIT_THRESHOLD orelse Count == 0 ->
+ infinity;
+ MemoryRatio < ?SUM_INC_THRESHOLD ->
+ ((Sum + ?SUM_INC_AMOUNT) / Count) / MemoryRatio;
+ true ->
+ (Sum / Count) / MemoryRatio
end,
State1 = State #state { desired_duration = DesiredDurationAvg1 },