diff options
| author | Matthias Radestock <matthias@lshift.net> | 2010-04-12 13:12:52 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2010-04-12 13:12:52 +0100 |
| commit | 1bb28855cdf86b1abb3f3c5300e0e5d0de5bd0a6 (patch) | |
| tree | dc97924eaf2f87d1bc4b773d8377019c76868b66 /src | |
| parent | f9f396f90d214abbecbd21361e78502c1b3ce42f (diff) | |
| download | rabbitmq-server-git-1bb28855cdf86b1abb3f3c5300e0e5d0de5bd0a6.tar.gz | |
refactor: inline rabbit_misc:random_geometric
it's a tiny fun and is only used in one place
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_misc.erl | 6 | ||||
| -rw-r--r-- | src/rabbit_msg_store.erl | 3 |
2 files changed, 2 insertions, 7 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 6be36a0def..136ca6fdea 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -60,7 +60,6 @@ -export([pid_to_string/1, string_to_pid/1]). -export([version_compare/2, version_compare/3]). -export([recursive_delete/1, dict_cons/3, unlink_and_capture_exit/1]). --export([random_geometric/1]). -import(mnesia). -import(lists). @@ -141,7 +140,6 @@ -spec(recursive_delete/1 :: (string()) -> 'ok' | {'error', any()}). -spec(dict_cons/3 :: (any(), any(), dict()) -> dict()). -spec(unlink_and_capture_exit/1 :: (pid()) -> 'ok'). --spec(random_geometric/1 :: (float()) -> non_neg_integer()). -endif. @@ -641,7 +639,3 @@ unlink_and_capture_exit(Pid) -> receive {'EXIT', Pid, _} -> ok after 0 -> ok end. - -random_geometric(P) when 0.0 < P andalso P < 1.0 -> - U = 1.0 - random:uniform(), - ceil(math:log(U) / math:log(1.0 - P)). diff --git a/src/rabbit_msg_store.erl b/src/rabbit_msg_store.erl index b6d6c5daa2..086f26b818 100644 --- a/src/rabbit_msg_store.erl +++ b/src/rabbit_msg_store.erl @@ -1444,7 +1444,8 @@ maybe_compact(State = #msstate { sum_valid_data = SumValid, file_summary_ets = FileSummaryEts }) when (SumFileSize - SumValid) / SumFileSize > ?GARBAGE_FRACTION -> First = ets:first(FileSummaryEts), - N = rabbit_misc:random_geometric(?GEOMETRIC_P), + N = rabbit_misc:ceil(math:log(1.0 - random:uniform()) / + math:log(1.0 - ?GEOMETRIC_P)), case find_files_to_gc(FileSummaryEts, N, First) of undefined -> State; |
