File 2023-Optimize-sys-handle_debug-4.patch of Package erlang

From 156a1af989f4977eb68e4c64feb79c55f2a0855d Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Tue, 23 Oct 2018 15:55:50 +0200
Subject: [PATCH 03/14] Optimize sys:handle_debug/4

---
 lib/stdlib/src/sys.erl | 30 ++++++++++++++++++++----------
 1 file 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) ->
     [].
-- 
2.16.4

openSUSE Build Service is sponsored by