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
What problem does this solve or what need does it fill?
bevy_utils::get_short_namereturns aString. 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 howfrom_utf8_lossyworks) would reduce allocation.What alternative(s) have you considered?
Sometimes,
get_short_nameis used for debug/display purposes. We could also provide a wrapper type that specifically implementsDisplayfor&strwith theget_short_nameheuristic to remove all type prefixes.Additional context
I saw a "hand made" version of
get_short_namein afmt::Debugimpl in asset_v2