From edd1fbc762b6e2c6022f8b8b81148fc8ebd7690c Mon Sep 17 00:00:00 2001 From: SisMaker <1713699517@qq.com> Date: Thu, 11 Nov 2021 18:28:27 +0800 Subject: [PATCH] =?UTF-8?q?ft:=20=E6=88=98=E6=96=97=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comMisc/utList.erl | 18 ++++++++++++++++++ src/srvNodeMgr/utVMInfo.erl | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/comMisc/utList.erl b/src/comMisc/utList.erl index 5a50a6e..5060626 100644 --- a/src/comMisc/utList.erl +++ b/src/comMisc/utList.erl @@ -10,6 +10,24 @@ -compile([export_all, nowarn_export_all]). +-spec getListVal(term(), list()) -> term(). +getListVal(Key, List) -> + case lists:keyfind(Key, 1, List) of + {_Key, Value} -> + Value; + _ -> + undefined + end. + +-spec getListVal(term(), list(), term()) -> term(). +getListVal(Key, List, Default) -> + case lists:keyfind(Key, 1, List) of + {_Key, Value} -> + Value; + _ -> + Default + end. + while(Fun, CurData) -> case Fun(CurData) of ?BREAK -> CurData; diff --git a/src/srvNodeMgr/utVMInfo.erl b/src/srvNodeMgr/utVMInfo.erl index d6f80e5..a1e73b0 100644 --- a/src/srvNodeMgr/utVMInfo.erl +++ b/src/srvNodeMgr/utVMInfo.erl @@ -167,7 +167,7 @@ show(N) -> F = fun(P) -> case catch process_info(P, [memory, dictionary]) of [{_, Memory}, {_, Dict}] -> - InitStart = util:prop_get_value('$initial_call', Dict, null), + InitStart = utList:getListVal('$initial_call', Dict, null), {InitStart, Memory}; _ -> {null, 0} end @@ -184,7 +184,7 @@ show(N, SkipNames) -> F = fun(P) -> case catch process_info(P, [memory, dictionary]) of [{_, Memory}, {_, Dict}] -> - InitStart = util:prop_get_value('$initial_call', Dict, null), + InitStart = utList:getListVal('$initial_call', Dict, null), case catch tuple_to_list(InitStart) of [Name | _] -> case lists:member(Name, SkipNames) of @@ -208,7 +208,7 @@ show1(N) -> F = fun(P, Acc) -> case catch process_info(P, [memory, dictionary]) of [{_, Memory}, {_, Dict}] -> - InitStart = util:prop_get_value('$initial_call', Dict, null), + InitStart = utList:getListVal('$initial_call', Dict, null), case lists:keyfind(InitStart, 1, Acc) of false -> [{InitStart, Memory, 1} | Acc]; {InitStart, Memory1, Num} -> lists:keystore(InitStart, 1, Acc, {InitStart, Memory + Memory1, Num + 1})