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

Impl Decode/Encode for Range/RangeInclusive #269

Merged
merged 2 commits into from
May 26, 2021
Merged

Conversation

c410-f3r
Copy link
Contributor

@c410-f3r c410-f3r commented May 24, 2021

Feel free to specify another deserialization/serialization format like (T, '=', T) if desirable.

src/codec.rs Outdated
Comment on lines 1219 to 1224
#[inline]
fn size_hint(&self) -> usize {
2 * mem::size_of::<T>()
}

#[inline]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[inline]
fn size_hint(&self) -> usize {
2 * mem::size_of::<T>()
}
#[inline]
fn size_hint(&self) -> usize {
2 * mem::size_of::<T>()
}

src/codec.rs Outdated
Comment on lines 1245 to 1249
#[inline]
fn size_hint(&self) -> usize {
2 * mem::size_of::<T>()
}

#[inline]
fn encode(&self) -> Vec<u8> {
(self.start(), self.end()).encode()
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[inline]
fn size_hint(&self) -> usize {
2 * mem::size_of::<T>()
}
#[inline]
fn encode(&self) -> Vec<u8> {
(self.start(), self.end()).encode()
}
fn size_hint(&self) -> usize {
2 * mem::size_of::<T>()
}
fn encode(&self) -> Vec<u8> {
(self.start(), self.end()).encode()
}

@c410-f3r
Copy link
Contributor Author

These functions are trivial one-line code candidates for #[inline] and sometimes the compiler generates layers of assembly jump indirections that could simply be inlined. In any case, all #[inline]s were removed.

@bkchr
Copy link
Member

bkchr commented May 26, 2021

I know what inline is doing. However, the compiler is most often smarter than any human and can already inline code if required.

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.

None yet

2 participants