mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Reduce size of XML stream state
This makes size of hibernated ejabberd_receiver a lot smaller (from ~290 words down to ~40).
This commit is contained in:
parent
4e6eff3f1a
commit
efc0b0ba5a
@ -49,33 +49,33 @@ process_data(CallbackPid, Stack, Data) ->
|
|||||||
if
|
if
|
||||||
Stack == [] ->
|
Stack == [] ->
|
||||||
catch gen_fsm:send_event(CallbackPid,
|
catch gen_fsm:send_event(CallbackPid,
|
||||||
{xmlstreamstart, Name, Attrs});
|
{xmlstreamstart, Name, Attrs}),
|
||||||
|
%% There is no need to store name or attributes of
|
||||||
|
%% stream opening element as it is not used
|
||||||
|
%% anymore.
|
||||||
|
[xmlstreamstart];
|
||||||
true ->
|
true ->
|
||||||
ok
|
[{xmlelement, Name, Attrs, []} | Stack]
|
||||||
end,
|
end;
|
||||||
[{xmlelement, Name, Attrs, []} | Stack];
|
|
||||||
{?XML_END, EndName} ->
|
{?XML_END, EndName} ->
|
||||||
case Stack of
|
case Stack of
|
||||||
[{xmlelement, Name, Attrs, Els} | Tail] ->
|
[xmlstreamstart] ->
|
||||||
|
catch gen_fsm:send_event(CallbackPid,
|
||||||
|
{xmlstreamend, EndName}),
|
||||||
|
[];
|
||||||
|
[{xmlelement, Name, Attrs, Els}, xmlstreamstart] ->
|
||||||
NewEl = {xmlelement, Name, Attrs, lists:reverse(Els)},
|
NewEl = {xmlelement, Name, Attrs, lists:reverse(Els)},
|
||||||
case Tail of
|
catch gen_fsm:send_event(CallbackPid,
|
||||||
[] ->
|
{xmlstreamelement, NewEl}),
|
||||||
catch gen_fsm:send_event(CallbackPid,
|
[xmlstreamstart];
|
||||||
{xmlstreamend, EndName}),
|
[{xmlelement, Name, Attrs, Els}, {xmlelement, Name1, Attrs1, Els1} | Tail] ->
|
||||||
Tail;
|
NewEl = {xmlelement, Name, Attrs, lists:reverse(Els)},
|
||||||
[_] ->
|
[{xmlelement, Name1, Attrs1, [NewEl | Els1]} | Tail]
|
||||||
catch gen_fsm:send_event(CallbackPid,
|
|
||||||
{xmlstreamelement, NewEl}),
|
|
||||||
Tail;
|
|
||||||
[{xmlelement, Name1, Attrs1, Els1} | Tail1] ->
|
|
||||||
[{xmlelement, Name1, Attrs1, [NewEl | Els1]} |
|
|
||||||
Tail1]
|
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
{?XML_CDATA, CData} ->
|
{?XML_CDATA, CData} ->
|
||||||
case Stack of
|
case Stack of
|
||||||
[El] ->
|
[xmlstreamstart] ->
|
||||||
[El];
|
[xmlstreamstart];
|
||||||
%% Merge CDATA nodes if they are contiguous
|
%% Merge CDATA nodes if they are contiguous
|
||||||
%% This does not change the semantic: the split in
|
%% This does not change the semantic: the split in
|
||||||
%% several CDATA nodes depends on the TCP/IP packet
|
%% several CDATA nodes depends on the TCP/IP packet
|
||||||
@ -187,4 +187,3 @@ process_element_events([Event | Events], Stack) ->
|
|||||||
{?XML_ERROR, Err} ->
|
{?XML_ERROR, Err} ->
|
||||||
{error, Err}
|
{error, Err}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user