perf(trie): do not call ets:info/2 to check if table is empty

emqx_trie table is a ordered_set, with write_concurrency set to
true, the counter is not centrialsed, the ets:info/2 call to
check size == 0 is very expensive
This commit is contained in:
Zaiming Shi 2021-05-06 16:53:51 +02:00 committed by turtleDeng
parent cfec4c9690
commit c81cd8550d
1 changed files with 1 additions and 1 deletions

View File

@ -122,7 +122,7 @@ match(Topic) when is_binary(Topic) ->
%% @doc Is the trie empty? %% @doc Is the trie empty?
-spec(empty() -> boolean()). -spec(empty() -> boolean()).
empty() -> ets:info(?TRIE, size) == 0. empty() -> ets:first(?TRIE) =:= '$end_of_table'.
-spec lock_tables() -> ok. -spec lock_tables() -> ok.
lock_tables() -> lock_tables() ->