summaryrefslogtreecommitdiff
path: root/src/rabbit_router.erl
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-09-12 17:18:38 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-09-12 17:18:38 +0100
commitc5126e4b19d2b5da1e8ad291fea29617c8b412ee (patch)
tree8e4c90af7107597f7b8d54e9df540af882bfe838 /src/rabbit_router.erl
parent9ffaa55446fbe90d145dd23cf48ae640f360bf84 (diff)
downloadrabbitmq-server-c5126e4b19d2b5da1e8ad291fea29617c8b412ee.tar.gz
Avoid traversing lists multiple times
Diffstat (limited to 'src/rabbit_router.erl')
-rw-r--r--src/rabbit_router.erl12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl
index c5a1c440..0fccd61b 100644
--- a/src/rabbit_router.erl
+++ b/src/rabbit_router.erl
@@ -43,7 +43,7 @@
-type(routing_key() :: binary()).
-type(routing_result() :: 'routed' | 'unroutable' | 'not_delivered').
--type(match_result() :: {[rabbit_amqqueue:name()], [rabbit_exchange:name()]}).
+-type(match_result() :: [rabbit_amqqueue:name() | rabbit_exchange:name()]).
-spec(deliver/2 ::
([pid()], rabbit_types:delivery()) -> {routing_result(), [pid()]}).
@@ -91,20 +91,14 @@ match_bindings(SrcName, Match) ->
mnesia:table(rabbit_route),
SrcName == SrcName1,
Match(Binding)]),
- partition_destinations(mnesia:async_dirty(fun qlc:e/1, [Query])).
+ mnesia:async_dirty(fun qlc:e/1, [Query]).
match_routing_key(SrcName, RoutingKey) ->
MatchHead = #route{binding = #binding{source = SrcName,
destination = '$1',
key = RoutingKey,
_ = '_'}},
- partition_destinations(
- mnesia:dirty_select(rabbit_route, [{MatchHead, [], ['$1']}])).
-
-partition_destinations(Destinations) ->
- lists:partition(
- fun (DestinationName) -> DestinationName#resource.kind =:= queue end,
- Destinations).
+ mnesia:dirty_select(rabbit_route, [{MatchHead, [], ['$1']}]).
%%--------------------------------------------------------------------