Skip to content

Commit 320265c

Browse files
committed
Reflect feedbacks
1 parent 01a5fa1 commit 320265c

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

vm/src/builtins/complex.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -420,21 +420,11 @@ impl Hashable for PyComplex {
420420
fn hash(zelf: &crate::Py<Self>, _vm: &VirtualMachine) -> PyResult<hash::PyHash> {
421421
let value = zelf.value;
422422

423-
let re_hash = (match hash::hash_float(value.re) {
424-
Some(value) => Some(value),
425-
None => Some(hash::hash_pointer(
426-
zelf as *const _ as *const std::ffi::c_void,
427-
)),
428-
})
429-
.unwrap();
423+
let re_hash = hash::hash_float(value.re)
424+
.unwrap_or_else(|| hash::hash_pointer(zelf as *const _ as *const std::ffi::c_void));
430425

431-
let im_hash = (match hash::hash_float(value.im) {
432-
Some(value) => Some(value),
433-
None => Some(hash::hash_pointer(
434-
zelf as *const _ as *const std::ffi::c_void,
435-
)),
436-
})
437-
.unwrap();
426+
let im_hash = hash::hash_float(value.im)
427+
.unwrap_or_else(|| hash::hash_pointer(zelf as *const _ as *const std::ffi::c_void));
438428

439429
let Wrapping(ret) = Wrapping(re_hash) + Wrapping(im_hash) * Wrapping(hash::IMAG);
440430
Ok(hash::fix_sentinel(ret))

vm/src/builtins/float.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,8 @@ impl Comparable for PyFloat {
539539
impl Hashable for PyFloat {
540540
#[inline]
541541
fn hash(zelf: &crate::Py<Self>, _vm: &VirtualMachine) -> PyResult<hash::PyHash> {
542-
match hash::hash_float(zelf.to_f64()) {
543-
Some(value) => Ok(value),
544-
None => Ok(hash::hash_pointer(
545-
zelf as *const _ as *const std::ffi::c_void,
546-
)),
547-
}
542+
Ok(hash::hash_float(zelf.to_f64())
543+
.unwrap_or_else(|| hash::hash_pointer(zelf as *const _ as *const libc::c_void)))
548544
}
549545
}
550546

0 commit comments

Comments
 (0)