-
Notifications
You must be signed in to change notification settings - Fork 12.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
Add #[inline]
to IpAddr methods
#83831
Add #[inline]
to IpAddr methods
#83831
Conversation
Add some inlines to trivial methods of IpAddr Closes #77583
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
Code from issue: use std::net::{Ipv4Addr, Ipv6Addr};
pub fn ipv4_bitand_mask(ipv4: Ipv4Addr, mask: u32) -> Ipv4Addr {
let ipv4_u32 = u32::from_ne_bytes(ipv4.octets());
Ipv4Addr::from((ipv4_u32 & mask).to_ne_bytes())
}
pub fn ipv6_bitand_mask(ipv6: Ipv6Addr, mask: u128) -> Ipv6Addr {
let ipv6_u128 = u128::from_ne_bytes(ipv6.octets());
Ipv6Addr::from((ipv6_u128 & mask).to_ne_bytes())
} Generated asm: _ZN9inline_ip16ipv4_bitand_mask17h21a1d58399eeef05E:
movl %ecx, %eax
andl %edx, %eax
retq
_ZN9inline_ip16ipv6_bitand_mask17h84a3a89719ccdfc1E:
movq %rcx, %rax
andq %r8, %rax
andq %r9, %rdx
retq I think, this change is very trivial. |
I'm not a reviewer. Maybe r? @m-ou-se |
Offtop: where can I find list of reviewers? |
Thanks! @bors r+ rollup
The list of reviewers that the high five bot will pick from is here: Everyone with bors review rights specifically for the library is listed here: https://www.rust-lang.org/governance/teams/library (And people of the compiler team sometimes also approve library changes that don't affect the public api.) |
📌 Commit a3d0fa8 has been approved by |
Thanks for the reply.
|
…ine-for-ip, r=m-ou-se Add `#[inline]` to IpAddr methods Add some inlines to trivial methods of IpAddr Closes rust-lang#77583
…ine-for-ip, r=m-ou-se Add `#[inline]` to IpAddr methods Add some inlines to trivial methods of IpAddr Closes rust-lang#77583
…ine-for-ip, r=m-ou-se Add `#[inline]` to IpAddr methods Add some inlines to trivial methods of IpAddr Closes rust-lang#77583
Rollup of 8 pull requests Successful merges: - rust-lang#81922 (Let `#[allow(unstable_name_collisions)]` work for things other than function) - rust-lang#82483 (Use FromStr trait for number option parsing) - rust-lang#82739 (Use the beta compiler for building bootstrap tools when `download-rustc` is set) - rust-lang#83650 (Update Source Serif to release 4.004) - rust-lang#83826 (List trait impls before deref methods in doc's sidebar) - rust-lang#83831 (Add `#[inline]` to IpAddr methods) - rust-lang#83863 (Render destructured struct function param names as underscore) - rust-lang#83865 (Don't report disambiguator error if link would have been ignored) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Should there be a test? |
@pickfire You mean codegen test? |
Not sure what is it called but to test the generated assembly. |
I don't see much use in testing that every single |
Add some inlines to trivial methods of IpAddr
Closes #77583