Просмотр исходного кода

ft: 战斗相关代码优化

master
SisMaker 3 лет назад
Родитель
Сommit
edd1fbc762
2 измененных файлов: 21 добавлений и 3 удалений
  1. +18
    -0
      src/comMisc/utList.erl
  2. +3
    -3
      src/srvNodeMgr/utVMInfo.erl

+ 18
- 0
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;

+ 3
- 3
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})

Загрузка…
Отмена
Сохранить