Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 19, 2013
@shino shino Utilize exported function information to avoid undef thrown
Elapsed time to export XML of one node with 1000 child elements are

Before: 7msec
> Xml = [{ham, [], lists:duplicate(1000, {eggs, [], ["bacon"]})}].
> timer:tc(fun() -> lists:foreach(fun(_) -> xmerl:export_simple(Xml, xmerl_xml) end,
                                  lists:seq(1,1000)) end).
{7043822,ok}

After: 1.3 msec/call
> Xml = [{ham, [], lists:duplicate(1000, {eggs, [], ["bacon"]})}].
> timer:tc(fun() -> lists:foreach(fun(_) -> xmerl:export_simple(Xml, xmerl_xml) end,
                                  lists:seq(1,1000)) end).
{1314278,ok}
e8e7d54
Showing with 12 additions and 9 deletions.
  1. +12 −9 lib/xmerl/src/xmerl.erl
View
21 lib/xmerl/src/xmerl.erl
@@ -274,7 +274,7 @@ tagdef(Tag,Pos,Parents,Args,CBs) ->
callbacks(Module) ->
Result = check_inheritance(Module, []),
%%% io:format("callbacks = ~p~n", [lists:reverse(Result)]),
- lists:reverse(Result).
+ gather_exports(Result, []).
callbacks([M|Mods], Visited) ->
case lists:member(M, Visited) of
@@ -296,6 +296,11 @@ check_inheritance(M, Visited) ->
callbacks(Mods, [M|Visited])
end.
+gather_exports([M|Mods], Acc) ->
+ gather_exports(Mods, [{M, M:module_info(exports)}|Acc]);
+gather_exports([], Acc) ->
+ Acc.
+
apply_text_cb(Ms, Text) ->
apply_cb(Ms, '#text#', '#text#', [Text]).
@@ -305,14 +310,12 @@ apply_tag_cb(Ms, F, Args) ->
apply_cb(Ms, F, Df, Args) ->
apply_cb(Ms, F, Df, Args, Ms).
-apply_cb([M|Ms], F, Df, Args, Ms0) ->
- case catch apply(M, F, Args) of
- {'EXIT', {undef,[{M,F,_,_}|_]}} ->
- apply_cb(Ms, F, Df, Args, Ms0);
- {'EXIT', Reason} ->
- exit(Reason);
- Res ->
- Res
+apply_cb([{M, Exports}|Ms], F, Df, Args, Ms0) ->
+ case lists:member({F, length(Args)}, Exports) of
+ true ->
+ apply(M, F, Args);
+ false ->
+ apply_cb(Ms, F, Df, Args, Ms0)
end;
apply_cb([], Df, Df, Args, _Ms0) ->
exit({unknown_tag, {Df, Args}});

No commit comments for this range

Something went wrong with that request. Please try again.