You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which seems kinda inefficient for a thing which is basically u32.
I guess part of the reason is the implementation which converts it to an array(!) first.
I copied the definition and implemented Ord like this:
impl Ord for Ipv4Addr2 {
fn cmp(&self, other: &Self) -> cmp::Ordering {
return Ord::cmp(&ntoh(self.inner.s_addr), &ntoh(other.inner.s_addr));
}
}
I'm using
Ipv4Addr
s as keys in a BtreeMap. I have to look up the map ~15 million times per second (10G ethernet line rate).Ipv4Addr cmp() compiles to this on my system (linux x86-64, rustc 1.10.0-nightly (476fe6e 2016-05-21))
Which seems kinda inefficient for a thing which is basically u32.
I guess part of the reason is the implementation which converts it to an array(!) first.
I copied the definition and implemented Ord like this:
It's about 10 times faster on my benchmark.
The text was updated successfully, but these errors were encountered: