perf(config): avoid build new map in emqx_mqtt_caps:get_caps
This commit is contained in:
parent
8e7ba2b6d1
commit
3d7201502b
|
@ -88,7 +88,7 @@ check_pub(Zone, Flags) when is_map(Flags) ->
|
||||||
error ->
|
error ->
|
||||||
Flags
|
Flags
|
||||||
end,
|
end,
|
||||||
maps:with(?PUBCAP_KEYS, get_caps(Zone))
|
get_caps(?PUBCAP_KEYS, Zone)
|
||||||
).
|
).
|
||||||
|
|
||||||
do_check_pub(#{topic_levels := Levels}, #{max_topic_levels := Limit}) when
|
do_check_pub(#{topic_levels := Levels}, #{max_topic_levels := Limit}) when
|
||||||
|
@ -111,7 +111,7 @@ 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 = maps:with(?SUBCAP_KEYS, get_caps(Zone)),
|
Caps = get_caps(?SUBCAP_KEYS, Zone),
|
||||||
Flags = lists:foldl(
|
Flags = lists:foldl(
|
||||||
fun
|
fun
|
||||||
(max_topic_levels, Map) ->
|
(max_topic_levels, Map) ->
|
||||||
|
@ -152,10 +152,12 @@ do_check_sub(_Flags, _Caps, _, _) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
get_caps(Zone) ->
|
get_caps(Zone) ->
|
||||||
lists:foldl(
|
get_caps(maps:keys(?DEFAULT_CAPS), Zone).
|
||||||
fun({K, V}, Acc) ->
|
get_caps(Keys, Zone) ->
|
||||||
Acc#{K => emqx_config:get_zone_conf(Zone, [mqtt, K], V)}
|
maps:with(
|
||||||
end,
|
Keys,
|
||||||
#{},
|
maps:merge(
|
||||||
maps:to_list(?DEFAULT_CAPS)
|
?DEFAULT_CAPS,
|
||||||
|
emqx_config:get_zone_conf(Zone, [mqtt])
|
||||||
|
)
|
||||||
).
|
).
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Reduce resource usage per MQTT packet handling.
|
||||||
|
|
Loading…
Reference in New Issue