-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: optimize HexString to use Cow<[u8]> for efficient memory usage #2675
Conversation
Thanks for the contribution! Before we can merge this, we need @wonderfan to sign the Fuel Labs Contributor License Agreement. |
thanks for your PR @wonderfan :) please let us know what you need from us |
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.
first pass, generally looks good, but it would be nice to remove any helpers which are unused
Ok(fuel_types::Nonce::from(bytes)) | ||
} | ||
} | ||
|
||
// Additional convenience methods | ||
impl HexString { | ||
pub fn as_bytes(&self) -> &[u8] { |
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.
pub fn as_bytes(&self) -> &[u8] { | |
/// View the HexString as a byte array. | |
pub fn as_bytes(&self) -> &[u8] { |
self.0.as_ref() | ||
} | ||
|
||
pub fn into_owned(self) -> Vec<u8> { |
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.
pub fn into_owned(self) -> Vec<u8> { | |
/// Extracts the owned data. | |
/// Clones the data if it is not already owned. | |
pub fn into_owned(self) -> Vec<u8> { |
self.0.into_owned() | ||
} | ||
|
||
pub fn from_static(bytes: &'static [u8]) -> Self { |
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.
pub fn from_static(bytes: &'static [u8]) -> Self { | |
/// Convert a static byte array to a HexString. | |
pub fn from_static(bytes: &'static [u8]) -> Self { |
@rymnc I try to optimize the codes, but it introduces other side effects after tests. As a result, i close this PR. |
Use this change set to fix #2657
Linked Issues/PRs
Description
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]