From bf0332a4d8bd464dce088eaabe0dbdbc028efe72 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Sun, 23 Jul 2023 01:38:48 +0800 Subject: [PATCH] simpler PartialOrd impl for CipherKey --- .../shadowsocks/src/relay/udprelay/aead_2022.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/crates/shadowsocks/src/relay/udprelay/aead_2022.rs b/crates/shadowsocks/src/relay/udprelay/aead_2022.rs index 4cf967fb..c8d85742 100644 --- a/crates/shadowsocks/src/relay/udprelay/aead_2022.rs +++ b/crates/shadowsocks/src/relay/udprelay/aead_2022.rs @@ -58,9 +58,7 @@ use std::{ use aes::{ cipher::{BlockDecrypt, BlockEncrypt, KeyInit}, - Aes128, - Aes256, - Block, + Aes128, Aes256, Block, }; use byte_string::ByteStr; use bytes::{Buf, BufMut, Bytes, BytesMut}; @@ -119,18 +117,7 @@ struct CipherKey { impl PartialOrd for CipherKey { fn partial_cmp(&self, other: &CipherKey) -> Option { - let hash1 = { - let mut hasher = DefaultHasher::new(); - self.hash(&mut hasher); - hasher.finish() - }; - let hash2 = { - let mut hasher = DefaultHasher::new(); - other.hash(&mut hasher); - hasher.finish() - }; - - hash1.partial_cmp(&hash2) + Some(self.cmp(other)) } }