diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2014-06-11 15:39:25 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2014-06-11 15:39:25 +0100 |
commit | a945dd39d70db21ef624f0612a44f1eca946472b (patch) | |
tree | 5d1b9d858d3a76048e11470ca3fd92ede472238c | |
parent | 7f185eb6544d440181a3c9f386c520c329842d0a (diff) | |
download | rabbitmq-server-a945dd39d70db21ef624f0612a44f1eca946472b.tar.gz |
Don't fail if asked to truncate a reference. And go to having a catch-all case.
-rw-r--r-- | src/truncate.erl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/truncate.erl b/src/truncate.erl index 3ead6f38..b959d21e 100644 --- a/src/truncate.erl +++ b/src/truncate.erl @@ -102,17 +102,17 @@ term_limit(Thing, Max) -> term_size(B, M, _W) when is_bitstring(B) -> lim(M, size(B)); term_size(A, M, W) when is_atom(A) -> lim(M, 2 * W); term_size(N, M, W) when is_number(N) -> lim(M, 2 * W); -term_size(F, M, W) when is_function(F) -> lim(M, erts_debug:flat_size(F) * W); -term_size(P, M, W) when is_pid(P) -> lim(M, erts_debug:flat_size(P) * W); term_size(T, M, W) when is_tuple(T) -> tuple_term_size( T, M, 1, tuple_size(T), W); -term_size([], M, _W) -> +term_size([], M, _W) -> M; term_size([H|T], M, W) -> case term_size(H, M, W) of limit_exceeded -> limit_exceeded; M2 -> lim(term_size(T, M2, W), 2 * W) - end. + end; +term_size(X, M, W) -> + lim(M, erts_debug:flat_size(X) * W); lim(S, T) when is_number(S) andalso S > T -> S - T; lim(_, _) -> limit_exceeded. @@ -156,6 +156,8 @@ test_short_examples_exactly() -> P = spawn(fun() -> receive die -> ok end end), F([0, 0.0, <<1:1>>, F, P], [0, 0.0, <<1:1>>, F, P]), P ! die, + R = make_ref(), + F([R], [R]), ok. test_term_limit() -> |