Skip to content
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

get_short_name should return a Cow most likely #2

Open
nicopap opened this issue Aug 19, 2023 · 2 comments
Open

get_short_name should return a Cow most likely #2

nicopap opened this issue Aug 19, 2023 · 2 comments

Comments

@nicopap
Copy link

nicopap commented Aug 19, 2023

What problem does this solve or what need does it fill?

bevy_utils::get_short_name returns a String. This results in unconditional allocation, even if the short name can be expressed as a slice of the full name.

What solution would you like?

Returning a Cow (similarly to how from_utf8_lossy works) would reduce allocation.

What alternative(s) have you considered?

Sometimes, get_short_name is used for debug/display purposes. We could also provide a wrapper type that specifically implements Display for &str with the get_short_name heuristic to remove all type prefixes.

Additional context

I saw a "hand made" version of get_short_name in a fmt::Debug impl in asset_v2

@rparrett
Copy link

get_short_name was moved to https://github.com/bevyengine/disqualified. Is this still relevant?

@BenjaminBrienen
Copy link

The issue should be moved

@mockersf mockersf transferred this issue from bevyengine/bevy Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants