From 945f9251364ec52ba7605784358403707bf7c11d Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Sun, 19 Nov 2017 01:15:22 +0800 Subject: [PATCH] Refactor the subscription_list function --- src/emqttd_mgmt.erl | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/emqttd_mgmt.erl b/src/emqttd_mgmt.erl index 6fffd71ff..01dd50b1e 100644 --- a/src/emqttd_mgmt.erl +++ b/src/emqttd_mgmt.erl @@ -455,15 +455,7 @@ subscription_list(Key, PageNo, PageSize) when ?EMPTY_KEY(Key) -> query_table(Qh, PageNo, PageSize, TotalNum); subscription_list(Key, PageNo, PageSize) -> - Keys = ets:lookup(mqtt_subscription, Key), - Fun = case length(Keys) == 0 of - true -> - fun() -> ets:match_object(mqtt_subproperty, {{Key, '_'}, '_'}) end; - false -> - fun() -> - lists:map(fun({S, T}) ->[R] = ets:lookup(mqtt_subproperty, {T, S}), R end, Keys) - end - end, + Fun = fun() -> ets:match_object(mqtt_subproperty, {{'_', {Key, '_'}}, '_'}) end, lookup_table(Fun, PageNo, PageSize). route_list(Topic, PageNo, PageSize) when ?EMPTY_KEY(Topic) ->