aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer
diff options
context:
space:
mode:
authorPeti Gomori <[email protected]>2012-06-29 18:25:59 +0200
committerHenrik Nord <[email protected]>2012-08-02 14:00:07 +0200
commit913aba26f8ae6186b8ae73f3b59ba8736411f9d7 (patch)
treef702f80680114613500a5eee11fb07b0189755e7 /lib/observer
parente223525ce20d4c7962994448d5ee632c4f229ec0 (diff)
downloadotp-913aba26f8ae6186b8ae73f3b59ba8736411f9d7.tar.gz
otp-913aba26f8ae6186b8ae73f3b59ba8736411f9d7.tar.bz2
otp-913aba26f8ae6186b8ae73f3b59ba8736411f9d7.zip
Make Table Viewer search a bit faster
Conflicts: lib/observer/src/observer_tv_table.erl
Diffstat (limited to 'lib/observer')
-rw-r--r--lib/observer/src/observer_tv_table.erl24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl
index 231a4c3108..835c7aafef 100644
--- a/lib/observer/src/observer_tv_table.erl
+++ b/lib/observer/src/observer_tv_table.erl
@@ -594,7 +594,7 @@ keysort(Col, Table) ->
lists:sort(Sort, Table).
search([Str, Row, Dir0, CaseSens],
- S=#holder{parent=Parent, table=Table}) ->
+ S=#holder{parent=Parent, table=Table0}) ->
Opt = case CaseSens of
true -> [];
false -> [caseless]
@@ -605,24 +605,28 @@ search([Str, Row, Dir0, CaseSens],
end,
Res = case re:compile(Str, Opt) of
{ok, Re} ->
+ Table =
+ case Dir0 of
+ true ->
+ lists:nthtail(Row, Table0);
+ false ->
+ lists:reverse(lists:sublist(Table0, Row+1))
+ end,
search(Row, Dir, Re, Table);
{error, _} -> false
end,
Parent ! {self(), Res},
S#holder{search=Res}.
-search(Row, Dir, Re, Table) ->
- Res = try lists:nth(Row+1, Table) of
- Term ->
- Str = format(Term),
- re:run(Str, Re)
- catch _:_ -> no_more
- end,
+search(Row, Dir, Re, [ [Term|_] |Table]) ->
+ Str = format(Term),
+ Res = re:run(Str, Re),
case Res of
nomatch -> search(Row+Dir, Dir, Re, Table);
- no_more -> false;
{match,_} -> Row
- end.
+ end;
+search(_, _, _, []) ->
+ false.
get_row(From, Row, Col, Table) ->
case lists:nth(Row+1, Table) of