perf(mqtt-caps): save some map builds
This commit is contained in:
parent
5f24526ab2
commit
4961aca3d0
|
@ -108,23 +108,12 @@ do_check_pub(_Flags, _Caps) ->
|
||||||
ok_or_error(emqx_types:reason_code()).
|
ok_or_error(emqx_types:reason_code()).
|
||||||
check_sub(ClientInfo = #{zone := Zone}, Topic, SubOpts) ->
|
check_sub(ClientInfo = #{zone := Zone}, Topic, SubOpts) ->
|
||||||
Caps = get_caps(?SUBCAP_KEYS, Zone),
|
Caps = get_caps(?SUBCAP_KEYS, Zone),
|
||||||
Flags = lists:foldl(
|
Flags = #{
|
||||||
fun
|
topic_levels => emqx_topic:levels(Topic),
|
||||||
(max_topic_levels, Map) ->
|
is_wildcard => emqx_topic:wildcard(Topic),
|
||||||
Map#{topic_levels => emqx_topic:levels(Topic)};
|
is_shared => maps:is_key(share, SubOpts),
|
||||||
(wildcard_subscription, Map) ->
|
is_exclusive => maps:get(is_exclusive, SubOpts, false)
|
||||||
Map#{is_wildcard => emqx_topic:wildcard(Topic)};
|
},
|
||||||
(shared_subscription, Map) ->
|
|
||||||
Map#{is_shared => maps:is_key(share, SubOpts)};
|
|
||||||
(exclusive_subscription, Map) ->
|
|
||||||
Map#{is_exclusive => maps:get(is_exclusive, SubOpts, false)};
|
|
||||||
%% Ignore
|
|
||||||
(_Key, Map) ->
|
|
||||||
Map
|
|
||||||
end,
|
|
||||||
#{},
|
|
||||||
maps:keys(Caps)
|
|
||||||
),
|
|
||||||
do_check_sub(Flags, Caps, ClientInfo, Topic).
|
do_check_sub(Flags, Caps, ClientInfo, Topic).
|
||||||
|
|
||||||
do_check_sub(#{topic_levels := Levels}, #{max_topic_levels := Limit}, _, _) when
|
do_check_sub(#{topic_levels := Levels}, #{max_topic_levels := Limit}, _, _) when
|
||||||
|
|
Loading…
Reference in New Issue