From b6c0fa46446181ce84b8856f12e50f33481065ff Mon Sep 17 00:00:00 2001 From: Diana Corbacho Date: Fri, 5 Feb 2016 13:20:14 +0000 Subject: [PATCH] Optimisation * Use lists:keyfind instead of proplists to speed up the management stats --- src/rabbit_misc.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 231db347..b7441375 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -882,8 +882,20 @@ is_process_alive(Pid) -> lists:member(Node, [node() | nodes()]) andalso rpc:call(Node, erlang, is_process_alive, [Pid]) =:= true. -pget(K, P) -> proplists:get_value(K, P). -pget(K, P, D) -> proplists:get_value(K, P, D). +pget(K, P) -> + case lists:keyfind(K, 1, P) of + {K, V} -> + V; + _ -> + undefined + end. +pget(K, P, D) -> + case lists:keyfind(K, 1, P) of + {K, V} -> + V; + _ -> + D + end. pget_or_die(K, P) -> case proplists:get_value(K, P) of