Skip to content

Commit a9344fd

Browse files
committed
fix: salt empty string
1 parent 610cd0d commit a9344fd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/evaluate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ impl Distribution {
7878
};
7979

8080
let salt = match &self.salt {
81-
None => eval_param.key,
82-
Some(s) => s,
81+
Some(s) if !s.is_empty() => s,
82+
_ => eval_param.key,
8383
};
8484

8585
let bucket_index = salt_hash(&hash_key, salt, 10000);
@@ -112,7 +112,6 @@ fn salt_hash(key: &str, salt: &str, bucket_size: u64) -> u32 {
112112
v.push(hax_value[i]);
113113
}
114114
let mut v = v.as_slice();
115-
116115
let value = v.read_u32::<BigEndian>().expect("can not be here");
117116
value % bucket_size as u32
118117
}

0 commit comments

Comments
 (0)