Merge pull request #10931 from qzhuyan/perf/william/save-times-of-maps-build
Perf/william/save times of maps build
This commit is contained in:
commit
c1be86c5ec
|
@ -84,7 +84,7 @@ check_pub(Zone, Flags) when is_map(Flags) ->
|
||||||
error ->
|
error ->
|
||||||
Flags
|
Flags
|
||||||
end,
|
end,
|
||||||
get_caps(?PUBCAP_KEYS, Zone)
|
emqx_config:get_zone_conf(Zone, [mqtt])
|
||||||
).
|
).
|
||||||
|
|
||||||
do_check_pub(#{topic_levels := Levels}, #{max_topic_levels := Limit}) when
|
do_check_pub(#{topic_levels := Levels}, #{max_topic_levels := Limit}) when
|
||||||
|
@ -107,24 +107,13 @@ 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 = emqx_config:get_zone_conf(Zone, [mqtt]),
|
||||||
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