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
Allocate Vec capacity based on size hints during decoding #293
Allocate Vec capacity based on size hints during decoding #293
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails CI. I guess there is a case where the code without with_capacity never end ups really allocating that much.
Ok I'm glad this happened since some malicious payloads could cause large memory allocation in my previous commit. Iterator should have the same effect to avoid reallocs and not allocate upfront |
I don't think that's true. The current version of the PR works the same as it did before the PR but using |
impl<T> Default for Topic<T> { | ||
fn default() -> Self { | ||
Topic::Any | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? I think you are changing behavior because the previous version still implemented Default when T wasn't Default while the new one doesn't. Either way, it's unrelated to the rest of the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no behaviour change, the compiler recommended this change in the CI failure.
this compiles fine:
#[test]
fn default_for_topic_T() {
struct Foo;
let f = Topic::<Foo>::default();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only changed it due to the CI failure, happy to keep or revert it either way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does CI fail because of that or is a warning? Apparently derive got smarter and it doesn't change behavior. I'm fine with keeping the change then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI failed, I actually think it was a clippy suggestion but it is configured to fail the job
Discovered this issue while profiling another crate