-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
proposal: use_of_instead_of_from
for collections.
#57106
Comments
I'd rather just deprecate & remove the |
If the |
Agree on just deprecating the old APIs. I don't want to have lint's for every API preference. There should be a good reason to make people avoid an existing non-deprecated API. |
@lrhn for some nuance, I'm not saying deprecate the old API. I'm just saying don't use The argument for deprecating |
@kevmoo Once it's deprecated - there's no longer a need for a new lint, is there? It's always better to make developers use the good path by making it the only path - instead of providing many knobs/hints/... - the fact that we have a need for so many hints (see here) is IMHO a bad smell. |
@lrhn @mkustermann – then let's do it. What's the recommended alternative for folks using
|
Literal. Using |
I was going to suggest we keep
But I realize that in the rare cases where you want all three of these, you could always use So +1 for getting rid of |
I think it's more clear to use +1 for deprecating |
I would also like to see the
If we are deprecating |
I'd love to make those better typed too. It's breaking. Don't know how much. (Will check!) Seems |
use_of_instead_of_from
Description
The
from
ctor on collections is more expensive. It does casts. If possible, use theof
constructor.Details
If the source collection has a known, compatible type statically,
of
should be used.Kind
Performance.
Bad Examples
Good Examples
Discussion
This should apply to
List
,Set
,Map
and related subtypes.See 6fae002
The text was updated successfully, but these errors were encountered: