aboutsummaryrefslogtreecommitdiffstats
path: root/lib/percept
diff options
context:
space:
mode:
Diffstat (limited to 'lib/percept')
-rw-r--r--lib/percept/src/egd_render.erl22
-rw-r--r--lib/percept/src/percept.erl8
-rw-r--r--lib/percept/src/percept.hrl3
-rw-r--r--lib/percept/src/percept_db.erl17
4 files changed, 22 insertions, 28 deletions
diff --git a/lib/percept/src/egd_render.erl b/lib/percept/src/egd_render.erl
index 4a0247dd33..7fd1072ab1 100644
--- a/lib/percept/src/egd_render.erl
+++ b/lib/percept/src/egd_render.erl
@@ -29,7 +29,8 @@
-include("egd.hrl").
-define('DummyC',0).
-binary(Image) -> binary(Image, opaque).
+binary(Image) ->
+ binary(Image, opaque).
binary(Image, Type) ->
parallel_binary(precompile(Image),Type).
@@ -42,9 +43,8 @@ parallel_binary(Image = #image{ height = Height },Type) ->
W = Image#image.width,
Bg = Image#image.background,
Os = Image#image.objects,
- erlang:list_to_binary(lists:map(fun
- (Y) -> scanline(Y, Os, {0,0,W - 1, Bg}, Type)
- end, lists:seq(1, Height)));
+ erlang:list_to_binary([scanline(Y, Os, {0,0,W - 1, Bg}, Type)
+ || Y <- lists:seq(1, Height)]);
Np ->
Pids = start_workers(Np, Type),
Handler = handle_workers(Height, Pids),
@@ -54,7 +54,9 @@ parallel_binary(Image = #image{ height = Height },Type) ->
Res
end.
-start_workers(Np, Type) -> start_workers(Np, Type, []).
+start_workers(Np, Type) ->
+ start_workers(Np, Type, []).
+
start_workers( 0, _, Pids) -> Pids;
start_workers(Np, Type, Pids) when Np > 0 ->
start_workers(Np - 1, Type, [spawn_link(fun() -> worker(Type) end)|Pids]).
@@ -90,7 +92,9 @@ init_workers(Image, Handler, [Pid|Pids]) ->
Handler ! {Pid, scan_complete},
init_workers(Image, Handler, Pids).
-handle_workers(H, Pids) -> spawn_link(fun() -> handle_workers(H, H, length(Pids)) end).
+handle_workers(H, Pids) ->
+ spawn_link(fun() -> handle_workers(H, H, length(Pids)) end).
+
handle_workers(_, 0, _) -> ok;
handle_workers(H, Hi, Np) when H > 0 ->
N = trunc(Hi/(2*Np)),
@@ -110,7 +114,9 @@ finish_workers([Pid|Pids]) ->
Pid ! {self(), done},
finish_workers(Pids).
-receive_binaries(H) -> receive_binaries(H, []).
+receive_binaries(H) ->
+ receive_binaries(H, []).
+
receive_binaries(0, Bins) -> erlang:list_to_binary(Bins);
receive_binaries(H, Bins) when H > 0 ->
receive
@@ -118,7 +124,6 @@ receive_binaries(H, Bins) when H > 0 ->
receive_binaries(H - 1, [Bin|Bins])
end.
-
scanline(Y, Os, {_,_,Width,_}=LSB, Type) ->
OLSs = parse_objects_on_line(Y-1, Width, Os),
RLSs = resulting_line_spans([LSB|OLSs],Type),
@@ -190,7 +195,6 @@ modify_layers(Layers,[{{_,Z,start},C}|Trans]) ->
modify_layers(Layers,[{{_,Z,stop },C}|Trans]) ->
modify_layers(remove_layer(Layers, Z, C), Trans).
-
add_layer([{Z1,_}=H|Layers],Z,C) when Z1 > Z ->
[H|add_layer(Layers,Z,C)];
add_layer(Layers,Z,C) ->
diff --git a/lib/percept/src/percept.erl b/lib/percept/src/percept.erl
index b0d6739478..f30c1dd585 100644
--- a/lib/percept/src/percept.erl
+++ b/lib/percept/src/percept.erl
@@ -251,20 +251,20 @@ trace_parser(Trace, {Count, Pid}) ->
find_service_pid_from_port([], _) ->
undefined;
find_service_pid_from_port([{_, Pid, Options} | Services], Port) ->
- case lists:keysearch(port, 1, Options) of
+ case lists:keyfind(port, 1, Options) of
false ->
find_service_pid_from_port(Services, Port);
- {value, {port, Port}} ->
+ {port, Port} ->
Pid
end.
find_service_port_from_pid([], _) ->
undefined;
find_service_port_from_pid([{_, Pid, Options} | _], Pid) ->
- case lists:keysearch(port, 1, Options) of
+ case lists:keyfind(port, 1, Options) of
false ->
undefined;
- {value, {port, Port}} ->
+ {port, Port} ->
Port
end;
find_service_port_from_pid([{_, _, _} | Services], Pid) ->
diff --git a/lib/percept/src/percept.hrl b/lib/percept/src/percept.hrl
index 3772a0164b..e383235b5d 100644
--- a/lib/percept/src/percept.hrl
+++ b/lib/percept/src/percept.hrl
@@ -40,8 +40,7 @@
runnable_count = 0 %:: non_neg_integer()
}).
--record(
- information, {
+-record(information, {
id ,%:: pid() | port(),
name = undefined ,%:: atom() | string() | 'undefined',
entry = undefined ,%:: true_mfa() | 'undefined',
diff --git a/lib/percept/src/percept_db.erl b/lib/percept/src/percept_db.erl
index df29381c57..0d66a6a9f6 100644
--- a/lib/percept/src/percept_db.erl
+++ b/lib/percept/src/percept_db.erl
@@ -392,23 +392,14 @@ consolidate_runnability_loop(Key) ->
consolidate_runnability_loop(ets:next(pdb_activity, Key)).
list_all_ts() ->
- ATs = [ Act#activity.timestamp ||
- Act <- select_query({activity, []})],
- STs = [ Act#activity.timestamp ||
- Act <- select_query({scheduler, []})],
+ ATs = [Act#activity.timestamp || Act <- select_query({activity, []})],
+ STs = [Act#activity.timestamp || Act <- select_query({scheduler, []})],
ITs = lists:flatten([
[I#information.start,
I#information.stop] ||
I <- select_query({information, all})]),
- % Filter out all undefined (non ts)
- TsList = lists:filter(
- fun(Element) ->
- case Element of
- {_,_,_} -> true;
- _ -> false
- end
- end, ATs ++ STs ++ ITs),
- TsList.
+ %% Filter out all undefined (non ts)
+ [Elem || Elem = {_,_,_} <- ATs ++ STs ++ ITs].
%% get_runnable_count(Type, State) -> RunnableCount
%% In: