Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
4161-Replace-uses-of-maps-map-and-maps-fold-wit...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4161-Replace-uses-of-maps-map-and-maps-fold-with-maps-for.patch of Package erlang
From e3f5947a4e84d22471d761cc85f35af8f0224ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muska=C5=82a?= <micmus@whatsapp.com> Date: Fri, 12 Feb 2021 11:04:43 +0100 Subject: [PATCH] Replace uses of maps:map and maps:fold with maps:foreach --- lib/kernel/src/net_kernel.erl | 21 ++++++++------------- lib/kernel/src/pg.erl | 2 +- lib/stdlib/src/shell_docs.erl | 2 +- lib/stdlib/src/supervisor.erl | 12 ++++++------ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl index 8dfae3a505..74fa6744ee 100644 --- a/lib/kernel/src/net_kernel.erl +++ b/lib/kernel/src/net_kernel.erl @@ -928,22 +928,18 @@ handle_info({From,badcookie,_To,_Mess}, State) -> %% handle_info(tick, State) -> ?tckr_dbg(tick), - ok = maps:fold(fun (Pid, _Node, ok) -> - Pid ! {self(), tick}, - ok - end, - ok, - State#state.conn_owners), + maps:foreach(fun (Pid, _Node) -> + Pid ! {self(), tick} + end, + State#state.conn_owners), {noreply,State}; handle_info(aux_tick, State) -> ?tckr_dbg(aux_tick), - ok = maps:fold(fun (Pid, _Node, ok) -> - Pid ! {self(), aux_tick}, - ok - end, - ok, - State#state.conn_owners), + maps:foreach(fun (Pid, _Node) -> + Pid ! {self(), aux_tick} + end, + State#state.conn_owners), {noreply,State}; handle_info(transition_period_end, diff --git a/lib/kernel/src/pg.erl b/lib/kernel/src/pg.erl index 37265a5db0..97741cc703 100644 --- a/lib/kernel/src/pg.erl +++ b/lib/kernel/src/pg.erl @@ -334,7 +334,7 @@ handle_info({'DOWN', MRef, process, Pid, _Info}, #state{scope = Scope, monitors %% handle remote node down or leaving overlay network handle_info({'DOWN', MRef, process, Pid, _Info}, #state{scope = Scope, nodes = Nodes} = State) -> {{MRef, RemoteMap}, NewNodes} = maps:take(Pid, Nodes), - _ = maps:map(fun (Group, Pids) -> leave_remote(Scope, Pids, [Group]) end, RemoteMap), + maps:foreach(fun (Group, Pids) -> leave_remote(Scope, Pids, [Group]) end, RemoteMap), {noreply, State#state{nodes = NewNodes}}; %% nodedown: ignore, and wait for 'DOWN' signal for monitored process diff --git a/lib/stdlib/src/shell_docs.erl b/lib/stdlib/src/shell_docs.erl index f041bbc5fa..d5f87ff243 100644 --- a/lib/stdlib/src/shell_docs.erl +++ b/lib/stdlib/src/shell_docs.erl @@ -114,7 +114,7 @@ validate_docs(hidden) -> validate_docs(none) -> ok; validate_docs(#{} = MDocs) -> - _ = maps:map(fun(_Key,MDoc) -> validate_docs(MDoc,[]) end, MDocs), + maps:foreach(fun(_Key,MDoc) -> validate_docs(MDoc,[]) end, MDocs), ok. validate_docs([H|T],Path) when is_tuple(H) -> _ = validate_docs(H,Path), diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index 7295a2e08e..dcd66f9596 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -933,21 +933,21 @@ terminate_dynamic_children(State) -> Sz = maps:size(Pids), EStack = case Child#child.shutdown of brutal_kill -> - maps:fold(fun(P, _, _) -> exit(P, kill) end, ok, Pids), + maps:foreach(fun(P, _) -> exit(P, kill) end, Pids), wait_dynamic_children(Child, Pids, Sz, undefined, EStack0); infinity -> - maps:fold(fun(P, _, _) -> exit(P, shutdown) end, ok, Pids), + maps:foreach(fun(P, _) -> exit(P, shutdown) end, Pids), wait_dynamic_children(Child, Pids, Sz, undefined, EStack0); Time -> - maps:fold(fun(P, _, _) -> exit(P, shutdown) end, ok, Pids), + maps:foreach(fun(P, _) -> exit(P, shutdown) end, Pids), TRef = erlang:start_timer(Time, self(), kill), wait_dynamic_children(Child, Pids, Sz, TRef, EStack0) end, %% Unroll stacked errors and report them - maps:fold(fun(Reason, Ls, _) -> + maps:foreach(fun(Reason, Ls) -> ?report_error(shutdown_error, Reason, Child#child{pid=Ls}, State#state.name) - end, ok, EStack). + end, EStack). monitor_dynamic_children(Child,State) -> dyn_fold(fun(P,{Pids, EStack}) when is_pid(P) -> @@ -1005,7 +1005,7 @@ wait_dynamic_children(Child, Pids, Sz, TRef, EStack) -> TRef, maps_prepend(Reason, Pid, EStack)); {timeout, TRef, kill} -> - maps:fold(fun(P, _, _) -> exit(P, kill) end, ok, Pids), + maps:foreach(fun(P, _) -> exit(P, kill) end, Pids), wait_dynamic_children(Child, Pids, Sz, undefined, EStack) end. -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor