File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,8 @@ impl Hash for Ipv4Addr {
7979 fn hash < H : Hasher > ( & self , state : & mut H ) {
8080 // Hashers are often more efficient at hashing a fixed-width integer
8181 // than a bytestring, so convert before hashing. We don't use to_bits()
82- // here as that involves a byteswap on little-endian machines, which are
83- // more common than big-endian machines.
84- u32:: from_le_bytes ( self . octets ) . hash ( state) ;
82+ // here as that may involve a byteswap which is unnecessary.
83+ u32:: from_ne_bytes ( self . octets ) . hash ( state) ;
8584 }
8685}
8786
@@ -172,9 +171,8 @@ impl Hash for Ipv6Addr {
172171 fn hash < H : Hasher > ( & self , state : & mut H ) {
173172 // Hashers are often more efficient at hashing a fixed-width integer
174173 // than a bytestring, so convert before hashing. We don't use to_bits()
175- // here as that involves byteswaps on little-endian machines, which are
176- // more common than big-endian machines.
177- u128:: from_le_bytes ( self . octets ) . hash ( state) ;
174+ // here as that may involve unnecessary byteswaps.
175+ u128:: from_ne_bytes ( self . octets ) . hash ( state) ;
178176 }
179177}
180178
You can’t perform that action at this time.
0 commit comments