Skip to content

Commit 5e18d89

Browse files
Merge pull request #9771 from rabbitmq/mergify/bp/v3.12.x/pr-9768
Optimise rabbit_registry:binary_to_type/1 (backport #9768)
2 parents 00e69cc + ca0edc1 commit 5e18d89

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

deps/rabbit_common/src/rabbit_registry.erl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ unregister(Class, TypeName) ->
4646
%% can throw a badarg, indicating that the type cannot have been
4747
%% registered.
4848
binary_to_type(TypeBin) when is_binary(TypeBin) ->
49-
case catch list_to_existing_atom(binary_to_list(TypeBin)) of
50-
{'EXIT', {badarg, _}} -> {error, not_found};
51-
TypeAtom -> TypeAtom
49+
case catch binary_to_existing_atom(TypeBin) of
50+
{'EXIT', {badarg, _}} ->
51+
{error, not_found};
52+
TypeAtom ->
53+
TypeAtom
5254
end.
5355

5456
lookup_module(Class, T) when is_atom(T) ->
@@ -65,7 +67,7 @@ lookup_all(Class) ->
6567
%%---------------------------------------------------------------------------
6668

6769
internal_binary_to_type(TypeBin) when is_binary(TypeBin) ->
68-
list_to_atom(binary_to_list(TypeBin)).
70+
binary_to_atom(TypeBin).
6971

7072
internal_register(Class, TypeName, ModuleName)
7173
when is_atom(Class), is_binary(TypeName), is_atom(ModuleName) ->

0 commit comments

Comments
 (0)