Skip to content

Commit

Permalink
simpler PartialOrd impl for CipherKey
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Jul 22, 2023
1 parent 2acda63 commit bf0332a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions crates/shadowsocks/src/relay/udprelay/aead_2022.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -119,18 +117,7 @@ struct CipherKey {

impl PartialOrd for CipherKey {
fn partial_cmp(&self, other: &CipherKey) -> Option<Ordering> {
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))
}
}

Expand Down

0 comments on commit bf0332a

Please sign in to comment.