summaryrefslogtreecommitdiff
path: root/src/pmon.erl
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-12-28 21:29:12 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2012-12-28 21:29:12 +0000
commit25bc0fabb9538906bf9b6eb0b72ae34e18fcf5c0 (patch)
tree9e019965a501b365a92562a3e009af7650fbc949 /src/pmon.erl
parent601f5b9fad8f64f9d4115765eec1e69602b058ed (diff)
downloadrabbitmq-server-25bc0fabb9538906bf9b6eb0b72ae34e18fcf5c0.tar.gz
optimise pmon:monitor_all common cases
Diffstat (limited to 'src/pmon.erl')
-rw-r--r--src/pmon.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pmon.erl b/src/pmon.erl
index 1aeebb72..37898119 100644
--- a/src/pmon.erl
+++ b/src/pmon.erl
@@ -19,6 +19,8 @@
-export([new/0, monitor/2, monitor_all/2, demonitor/2, is_monitored/2, erase/2,
monitored/1, is_empty/1]).
+-compile({no_auto_import, [monitor/2]}).
+
-ifdef(use_specs).
%%----------------------------------------------------------------------------
@@ -48,7 +50,9 @@ monitor(Item, M) ->
false -> dict:store(Item, erlang:monitor(process, Item), M)
end.
-monitor_all(Items, M) -> lists:foldl(fun monitor/2, M, Items).
+monitor_all([], M) -> M; %% optimisation
+monitor_all([Item], M) -> monitor(Item, M); %% optimisation
+monitor_all(Items, M) -> lists:foldl(fun monitor/2, M, Items).
demonitor(Item, M) ->
case dict:find(Item, M) of