summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Harrop <rob@rabbitmq.com>2011-03-08 15:56:23 +0000
committerRob Harrop <rob@rabbitmq.com>2011-03-08 15:56:23 +0000
commitfb963d270c9f04beeba1b1f8377f91b6b20ed736 (patch)
tree2822eb52e89830e32703d887ee2bc35b41913231 /src
parentef5f4b72bebde582a3fd531f4bd1f6787f032a14 (diff)
downloadrabbitmq-server-git-fb963d270c9f04beeba1b1f8377f91b6b20ed736.tar.gz
Tweaked accumulator again - no need to store the entire path
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_exchange_type_topic.erl19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/rabbit_exchange_type_topic.erl b/src/rabbit_exchange_type_topic.erl
index 7cff129ca1..655182878e 100644
--- a/src/rabbit_exchange_type_topic.erl
+++ b/src/rabbit_exchange_type_topic.erl
@@ -85,7 +85,7 @@ remove_bindings(true, X, Bs) ->
[trie_remove_binding(X, FinalNode, D) || {FinalNode, D} <- ToDelete],
[trie_remove_edge(X, Parent, Node, W) ||
- {Node, {[{Node, W}, {Parent, _} | _], 0, 0}}
+ {Node, {Parent, W, {0, 0}}}
<- gb_trees:to_list(Paths)],
ok;
remove_bindings(false, _X, _Bs) ->
@@ -101,25 +101,26 @@ maybe_add_path(X, Path = [{Node, _} | _], PathAcc) ->
decrement_bindings(X, Path, PathAcc) ->
with_path_acc(X,
- fun({_Path, Bindings, Edges}) ->
- {Path, Bindings - 1, Edges}
+ fun({Bindings, Edges}) ->
+ {Bindings - 1, Edges}
end,
Path, PathAcc).
decrement_edges(X, Path, PathAcc) ->
with_path_acc(X,
- fun({_Path, Bindings, Edges}) ->
- {Path, Bindings, Edges - 1}
+ fun({Bindings, Edges}) ->
+ {Bindings, Edges - 1}
end,
Path, PathAcc).
with_path_acc(_X, _Fun, [{root, none}], PathAcc) ->
PathAcc;
with_path_acc(X, Fun, [{Node, _} | ParentPath], PathAcc) ->
- NewVal = Fun(gb_trees:get(Node, PathAcc)),
- NewPathAcc = gb_trees:update(Node, NewVal, PathAcc),
- case NewVal of
- {_, 0, 0} ->
+ {Parent, W, Counts} = gb_trees:get(Node, PathAcc),
+ NewCounts = Fun(Counts),
+ NewPathAcc = gb_trees:update(Node, {Parent, W, NewCounts}, PathAcc),
+ case NewCounts of
+ {0, 0} ->
decrement_edges(X, ParentPath,
maybe_add_path(X, ParentPath, NewPathAcc));
_ ->