Skip to content

Commit 0d32e1a

Browse files
committed
Relocate vm._hash to obj.hash
1 parent 6e6a9f6 commit 0d32e1a

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

vm/src/builtins/genericalias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn make_parameters(args: &PyTupleRef, vm: &VirtualMachine) -> PyTupleRef {
167167
impl Hashable for PyGenericAlias {
168168
#[inline]
169169
fn hash(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<hash::PyHash> {
170-
Ok(vm._hash(zelf.origin.as_object())? ^ vm._hash(zelf.args.as_object())?)
170+
Ok(zelf.origin.as_object().hash(vm)? ^ zelf.args.as_object().hash(vm)?)
171171
}
172172
}
173173

vm/src/builtins/weakref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Hashable for PyWeak {
9393
let obj = zelf
9494
.upgrade()
9595
.ok_or_else(|| vm.new_type_error("weak object has gone away".to_owned()))?;
96-
let hash = vm._hash(&obj)?;
96+
let hash = obj.hash(vm)?;
9797
zelf.hash.store(Some(hash));
9898
Ok(hash)
9999
}

vm/src/dictdatatype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ pub trait DictKey: IntoPyObject {
652652
/// to index dictionaries.
653653
impl DictKey for PyObjectRef {
654654
fn key_hash(&self, vm: &VirtualMachine) -> PyResult<HashValue> {
655-
vm._hash(self)
655+
self.hash(vm)
656656
}
657657

658658
fn key_is(&self, other: &PyObjectRef) -> bool {

vm/src/stdlib/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ mod builtins {
337337

338338
#[pyfunction]
339339
fn hash(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyHash> {
340-
vm._hash(&obj)
340+
obj.hash(vm)
341341
}
342342

343343
// builtin_help

vm/src/stdlib/sre.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ mod _sre {
517517

518518
impl Hashable for Pattern {
519519
fn hash(zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
520-
let hash = vm._hash(&zelf.pattern)?;
520+
let hash = zelf.pattern.hash(vm)?;
521521
let (_, code, _) = unsafe { zelf.code.align_to::<u8>() };
522522
let hash = hash ^ vm.state.hash_secret.hash_bytes(code);
523523
let hash = hash ^ (zelf.flags.bits() as PyHash);

vm/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ pub fn hash_iter<'a, I: IntoIterator<Item = &'a PyObjectRef>>(
7575
iter: I,
7676
vm: &VirtualMachine,
7777
) -> PyResult<rustpython_common::hash::PyHash> {
78-
vm.state.hash_secret.hash_iter(iter, |obj| vm._hash(obj))
78+
vm.state.hash_secret.hash_iter(iter, |obj| obj.hash(vm))
7979
}
8080

8181
pub fn hash_iter_unordered<'a, I: IntoIterator<Item = &'a PyObjectRef>>(
8282
iter: I,
8383
vm: &VirtualMachine,
8484
) -> PyResult<rustpython_common::hash::PyHash> {
85-
rustpython_common::hash::hash_iter_unordered(iter, |obj| vm._hash(obj))
85+
rustpython_common::hash::hash_iter_unordered(iter, |obj| obj.hash(vm))
8686
}
8787

8888
// TODO: find a better place to put this impl

0 commit comments

Comments
 (0)