perf(emqx_placeholder): do not try to decode maps as json
fix
This commit is contained in:
parent
2908da4a8a
commit
327080e70e
|
@ -265,11 +265,16 @@ lookup_var(Var, Value) when Var == ?PH_VAR_THIS orelse Var == [] ->
|
||||||
Value;
|
Value;
|
||||||
lookup_var([Prop | Rest], Data0) ->
|
lookup_var([Prop | Rest], Data0) ->
|
||||||
Data =
|
Data =
|
||||||
|
case is_map(Data0) of
|
||||||
|
true ->
|
||||||
|
Data0;
|
||||||
|
false ->
|
||||||
case emqx_utils_json:safe_decode(Data0, [return_maps]) of
|
case emqx_utils_json:safe_decode(Data0, [return_maps]) of
|
||||||
{ok, Data1} ->
|
{ok, Data1} ->
|
||||||
Data1;
|
Data1;
|
||||||
{error, _} ->
|
{error, _} ->
|
||||||
Data0
|
Data0
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
case lookup(Prop, Data) of
|
case lookup(Prop, Data) of
|
||||||
{ok, Value} ->
|
{ok, Value} ->
|
||||||
|
@ -293,12 +298,10 @@ lookup(Prop, Data) when is_binary(Prop) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_one_lookup(Key, Data) ->
|
do_one_lookup(Key, Data) ->
|
||||||
try
|
case Data of
|
||||||
{ok, maps:get(Key, Data)}
|
#{Key := Value} ->
|
||||||
catch
|
{ok, Value};
|
||||||
error:{badkey, _} ->
|
_ ->
|
||||||
{error, undefined};
|
|
||||||
error:{badmap, _} ->
|
|
||||||
{error, undefined}
|
{error, undefined}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Improve performance of template rendering in bridges.
|
Loading…
Reference in New Issue