You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preallocation of maps can be useful, as shown by PR #23, would be nice to have prealloc suggest that too.
Just wondering how smart it can be made as things are not as straightforward as with slices because there's key uniqueness at play. Cases where the optimal preallocated capacity can be easily determined beforehand are more rare with maps, and in that sense suggesting it could have a worse signal to noise ratio. Maybe it should be made optional if it can't be made "smart enough" 🤔
The text was updated successfully, but these errors were encountered:
Hey there, thanks for the issue! I'm not sure if we can realistically determine whether or not a given range or for loop with have duplicate key insertions into a map (we simply don't have access to that information using the AST). We could potentially suggest capacity hints, but as you mentioned, I think this may end up having more false positives than anything.
Happy to entertain contributions if you feel you can come up with something, feel free to experiment/open a PR 😄
Preallocation of maps can be useful, as shown by PR #23, would be nice to have prealloc suggest that too.
Just wondering how smart it can be made as things are not as straightforward as with slices because there's key uniqueness at play. Cases where the optimal preallocated capacity can be easily determined beforehand are more rare with maps, and in that sense suggesting it could have a worse signal to noise ratio. Maybe it should be made optional if it can't be made "smart enough" 🤔
The text was updated successfully, but these errors were encountered: