-
Notifications
You must be signed in to change notification settings - Fork 287
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
refactor: avoid unnecessary allocation #3747
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3747 +/- ##
==========================================
- Coverage 85.65% 85.30% -0.36%
==========================================
Files 944 944
Lines 158776 158772 -4
==========================================
- Hits 135997 135437 -560
- Misses 22779 23335 +556 |
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.
When you use Vec<&'a [u8]>
, an extra allocation happen at
PutRequest::new()
.with_key(key.into_bytes())
.with_value(value),
where
pub fn with_value(mut self, value: impl Into<Vec<u8>>) -> Self {
self.value = value.into();
self
}
impl<T: Clone> From<&[T]> for Vec<T> {
fn from(s: &[T]) -> Vec<T> {
/// Allocate a `Vec<T>` and fill it by cloning `s`'s items.
s.to_vec()
}
}
See also #3740 (comment)
Got it. I'm going to close this @WenyXu |
But actually |
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
avoid unnecessary allocation
Checklist