Skip to content

Optimise rabbit_registry:binary_to_type/1 (backport #9768) #9771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions deps/rabbit_common/src/rabbit_registry.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ unregister(Class, TypeName) ->
%% can throw a badarg, indicating that the type cannot have been
%% registered.
binary_to_type(TypeBin) when is_binary(TypeBin) ->
case catch list_to_existing_atom(binary_to_list(TypeBin)) of
{'EXIT', {badarg, _}} -> {error, not_found};
TypeAtom -> TypeAtom
case catch binary_to_existing_atom(TypeBin) of
{'EXIT', {badarg, _}} ->
{error, not_found};
TypeAtom ->
TypeAtom
end.

lookup_module(Class, T) when is_atom(T) ->
Expand All @@ -65,7 +67,7 @@ lookup_all(Class) ->
%%---------------------------------------------------------------------------

internal_binary_to_type(TypeBin) when is_binary(TypeBin) ->
list_to_atom(binary_to_list(TypeBin)).
binary_to_atom(TypeBin).

internal_register(Class, TypeName, ModuleName)
when is_atom(Class), is_binary(TypeName), is_atom(ModuleName) ->
Expand Down