diff options
author | Raimo Niskanen <[email protected]> | 2018-10-23 15:55:50 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2018-11-16 14:40:44 +0100 |
commit | 156a1af989f4977eb68e4c64feb79c55f2a0855d (patch) | |
tree | 77156a3cbeba491e272c7fb83f8dbcbc1b46e557 | |
parent | 6f0a9a08023ea4825dbdcefae0d976b08566729a (diff) | |
download | otp-156a1af989f4977eb68e4c64feb79c55f2a0855d.tar.gz otp-156a1af989f4977eb68e4c64feb79c55f2a0855d.tar.bz2 otp-156a1af989f4977eb68e4c64feb79c55f2a0855d.zip |
Optimize sys:handle_debug/4
-rw-r--r-- | lib/stdlib/src/sys.erl | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/stdlib/src/sys.erl b/lib/stdlib/src/sys.erl index 7b161460b0..8e12b3ff8d 100644 --- a/lib/stdlib/src/sys.erl +++ b/lib/stdlib/src/sys.erl @@ -385,31 +385,41 @@ handle_system_msg(SysState, Msg, From, Parent, Mod, Debug, Misc, Hib) -> FormFunc :: format_fun(), Extra :: term(), Event :: system_event(). -handle_debug([{trace, true} | T], FormFunc, State, Event) -> +handle_debug([{trace, true} = DbgOpt | T], FormFunc, State, Event) -> print_event({Event, State, FormFunc}), - [{trace, true} | handle_debug(T, FormFunc, State, Event)]; + [DbgOpt | handle_debug(T, FormFunc, State, Event)]; handle_debug([{log, NLog} | T], FormFunc, State, Event) -> Item = {Event, State, FormFunc}, [{log, nlog_put(Item, NLog)} | handle_debug(T, FormFunc, State, Event)]; -handle_debug([{log_to_file, Fd} | T], FormFunc, State, Event) -> +handle_debug([{log_to_file, Fd} = DbgOpt | T], FormFunc, State, Event) -> print_event(Fd, {Event, State, FormFunc}), - [{log_to_file, Fd} | handle_debug(T, FormFunc, State, Event)]; + [DbgOpt | handle_debug(T, FormFunc, State, Event)]; handle_debug([{statistics, StatData} | T], FormFunc, State, Event) -> NStatData = stat(Event, StatData), [{statistics, NStatData} | handle_debug(T, FormFunc, State, Event)]; handle_debug([{FuncId, {Func, FuncState}} | T], FormFunc, State, Event) -> - case catch Func(FuncState, Event, State) of + try Func(FuncState, Event, State) of done -> handle_debug(T, FormFunc, State, Event); - {'EXIT', _} -> handle_debug(T, FormFunc, State, Event); NFuncState -> - [{FuncId, {Func, NFuncState}} | handle_debug(T, FormFunc, State, Event)] + [{FuncId, {Func, NFuncState}} | + handle_debug(T, FormFunc, State, Event)] + catch + done -> handle_debug(T, FormFunc, State, Event); + NFuncState -> + [{FuncId, {Func, NFuncState}} | + handle_debug(T, FormFunc, State, Event)]; + _:_ -> handle_debug(T, FormFunc, State, Event) end; handle_debug([{Func, FuncState} | T], FormFunc, State, Event) -> - case catch Func(FuncState, Event, State) of + try Func(FuncState, Event, State) of done -> handle_debug(T, FormFunc, State, Event); - {'EXIT', _} -> handle_debug(T, FormFunc, State, Event); - NFuncState -> + NFuncState -> [{Func, NFuncState} | handle_debug(T, FormFunc, State, Event)] + catch + done -> handle_debug(T, FormFunc, State, Event); + NFuncState -> + [{Func, NFuncState} | handle_debug(T, FormFunc, State, Event)]; + _:_ -> handle_debug(T, FormFunc, State, Event) end; handle_debug([], _FormFunc, _State, _Event) -> []. |