Skip to content

Commit

Permalink
Merge pull request #3637 from esl/perf/origin_stanza_acc
Browse files Browse the repository at this point in the history
Skip pretty-printing of unused accumulator field
  • Loading branch information
chrzaszcz authored Apr 26, 2022
2 parents f5b511c + 6189d6d commit c53ce7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
12 changes: 4 additions & 8 deletions src/mongoose_acc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
timestamp := integer(), %microsecond
origin_pid := pid(),
origin_location := location(),
origin_stanza := binary() | undefined,
stanza := stanza_metadata() | undefined,
lserver := jid:lserver(),
host_type := binary() | undefined,
Expand Down Expand Up @@ -124,19 +123,17 @@

-spec new(Params :: new_acc_params()) -> t().
new(#{ location := Location, lserver := LServer } = Params) ->
{ElementBin, Stanza} =
case maps:get(element, Params, undefined) of
undefined -> {undefined, undefined};
Element -> {exml:to_binary(Element), stanza_from_params(Params)}
end,
Stanza = case maps:get(element, Params, undefined) of
undefined -> undefined;
_Element -> stanza_from_params(Params)
end,
HostType = get_host_type(Params),
#{
mongoose_acc => true,
ref => make_ref(),
timestamp => os:system_time(microsecond),
origin_pid => self(),
origin_location => Location,
origin_stanza => ElementBin,
stanza => Stanza,
lserver => LServer,
host_type => HostType,
Expand Down Expand Up @@ -341,7 +338,6 @@ default_non_strippable() ->
timestamp,
origin_pid,
origin_location,
origin_stanza,
stanza,
lserver,
host_type,
Expand Down
11 changes: 4 additions & 7 deletions test/json_formatter_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -346,21 +346,18 @@ large_event_dont_crash_formatter(_Config) ->
%%

example_acc(Body) ->
Elem = {xmlel, <<"message">>,
[{<<"type">>, <<"chat">>}, {<<"id">>, <<"1111">>}],
[{xmlel, <<"body">>,[], [{xmlcdata, Body}]}]},
#{lserver => <<"localhost">>,
mongoose_acc => true,
non_strippable => [],
origin_location => #{file => "/Users/user/MongooseIM/src/ejabberd_router.erl",
line => 116,
mfa => {ejabberd_router,route,3}},
origin_pid => self(),
origin_stanza => <<"<message type='chat' id='1111'><body>",
Body/binary,
"</body></message>">>,
ref => make_ref(),
stanza => #{element => {xmlel,<<"message">>,
[{<<"type">>,<<"chat">>},{<<"id">>,<<"1111">>}],
[{xmlel,<<"body">>,[],
[{xmlcdata,Body}]}]},
stanza => #{element => Elem,
from_jid => {jid,<<"userA">>,<<"localhost">>,<<>>,<<"usera">>,<<"localhost">>,<<>>},
name => <<"message">>,
ref => make_ref(),
Expand Down

0 comments on commit c53ce7a

Please sign in to comment.