Skip to content
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

Add convenience impls for common types #137

Merged
merged 6 commits into from
Jan 27, 2024
Merged

Conversation

Pratyush
Copy link
Member

Description

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@Pratyush Pratyush requested a review from a team as a code owner January 18, 2024 03:26
@Pratyush Pratyush requested review from z-tech, mmagician and weikengchen and removed request for a team January 18, 2024 03:26
src/eq.rs Outdated Show resolved Hide resolved
src/eq.rs Outdated Show resolved Hide resolved
@Pratyush Pratyush requested review from mmagician and removed request for mmagician January 26, 2024 02:49
Copy link
Member

@mmagician mmagician left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question on the logic, otherwise LGTM

let elem = elem.to_bytes_le()?;
bytes.extend_from_slice(&elem);
// Make sure that there's enough capacity to avoid reallocations.
bytes.reserve(elem.len() * (self.len() - 1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we do this at each iteration of the loop in case the elements have different len?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually wasn't the smartest logic, but it kind of works out: if the elem.len() is less than or equal to that for previous elems, then don't change the capacity, resulting in a no-op. If elem.len() is larger than that for previous elems, it will reserve more space.

@mmagician mmagician merged commit 4020fbc into master Jan 27, 2024
11 checks passed
@mmagician mmagician deleted the add-convenience-impls branch January 27, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants