Skip to content

Commit 8c7def0

Browse files
committed
Address review
1 parent 1da239a commit 8c7def0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

common/src/refcount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl RefCount {
3030
}
3131

3232
#[inline]
33-
pub fn incref(&self) {
33+
pub fn inc(&self) {
3434
let old_size = self.strong.fetch_add(1, Relaxed);
3535

3636
if old_size > MAX_REFCOUNT {
@@ -40,7 +40,7 @@ impl RefCount {
4040

4141
/// Decrement the reference count. Returns true when the refcount drops to 0.
4242
#[inline]
43-
pub fn decref(&self) -> bool {
43+
pub fn dec(&self) -> bool {
4444
if self.strong.fetch_sub(1, Release) != 1 {
4545
return false;
4646
}

vm/src/pyobjectrc.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ impl PyWeak {
318318
let guard = unsafe { self.parent.as_ref().lock() };
319319
let obj_ptr = guard.obj?;
320320
unsafe {
321-
obj_ptr.as_ref().0.refcount.incref();
321+
obj_ptr.as_ref().0.refcount.inc();
322322
Some(PyObjectRef::from_raw(obj_ptr.as_ptr()))
323323
}
324324
}
@@ -464,7 +464,7 @@ impl ToOwned for PyObject {
464464

465465
#[inline(always)]
466466
fn to_owned(&self) -> Self::Owned {
467-
self.0.refcount.incref();
467+
self.0.refcount.inc();
468468
PyObjectRef {
469469
ptr: NonNull::from(self),
470470
}
@@ -569,7 +569,7 @@ impl PyObjectRef {
569569

570570
impl PyObject {
571571
#[inline]
572-
fn weakreflist(&self) -> Option<&WeakRefList> {
572+
fn weak_ref_list(&self) -> Option<&WeakRefList> {
573573
Some(&self.0.weaklist)
574574
}
575575

@@ -579,8 +579,8 @@ impl PyObject {
579579
// a reference to weakref_type **specifically**
580580
typ: PyTypeRef,
581581
) -> Option<PyObjectWeak> {
582-
self.weakreflist()
583-
.map(|wr| wr.add(self, typ, true, callback, None))
582+
self.weak_ref_list()
583+
.map(|wrl| wrl.add(self, typ, true, callback, None))
584584
}
585585

586586
pub(crate) fn downgrade_with_typ(
@@ -599,8 +599,8 @@ impl PyObject {
599599
None
600600
};
601601
let cls_is_weakref = typ.is(&vm.ctx.types.weakref_type);
602-
self.weakreflist()
603-
.map(|wr| wr.add(self, typ, cls_is_weakref, callback, dict))
602+
self.weak_ref_list()
603+
.map(|wrl| wrl.add(self, typ, cls_is_weakref, callback, dict))
604604
.ok_or_else(|| {
605605
vm.new_type_error(format!(
606606
"cannot create weak reference to '{}' object",
@@ -618,7 +618,7 @@ impl PyObject {
618618
}
619619

620620
pub fn get_weak_references(&self) -> Option<Vec<PyObjectWeak>> {
621-
self.weakreflist().map(|wrl| wrl.get_weak_references())
621+
self.weak_ref_list().map(|wrl| wrl.get_weak_references())
622622
}
623623

624624
pub fn payload_is<T: PyObjectPayload>(&self) -> bool {
@@ -705,7 +705,7 @@ impl PyObject {
705705

706706
#[inline]
707707
pub fn weak_count(&self) -> Option<usize> {
708-
self.weakreflist().map(|wrl| wrl.count())
708+
self.weak_ref_list().map(|wrl| wrl.count())
709709
}
710710

711711
#[inline]
@@ -721,11 +721,11 @@ impl PyObjectRef {
721721
// CPython-compatible drop implementation
722722
if let Some(slot_del) = self.class().mro_find_map(|cls| cls.slots.del.load()) {
723723
let ret = crate::vm::thread::with_vm(self, |vm| {
724-
self.0.refcount.incref();
724+
self.0.refcount.inc();
725725
if let Err(e) = slot_del(self, vm) {
726726
print_del_error(e, self, vm);
727727
}
728-
self.0.refcount.decref()
728+
self.0.refcount.dec()
729729
});
730730
match ret {
731731
// the decref right above set refcount back to 0
@@ -737,7 +737,7 @@ impl PyObjectRef {
737737
}
738738
}
739739
}
740-
if let Some(wrl) = self.weakreflist() {
740+
if let Some(wrl) = self.weak_ref_list() {
741741
wrl.clear();
742742
}
743743

@@ -804,7 +804,7 @@ impl PyObjectWeak {
804804

805805
impl Drop for PyObjectRef {
806806
fn drop(&mut self) {
807-
if self.0.refcount.decref() {
807+
if self.0.refcount.dec() {
808808
self.drop_slow()
809809
}
810810
}
@@ -1093,12 +1093,12 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef, PyTypeRef) {
10931093
type_type_ptr as *mut MaybeUninit<PyInner<PyType>> as *mut PyInner<PyType>;
10941094

10951095
unsafe {
1096-
(*type_type_ptr).refcount.incref();
1096+
(*type_type_ptr).refcount.inc();
10971097
ptr::write(
10981098
&mut (*object_type_ptr).typ as *mut PyRwLock<PyTypeRef> as *mut UninitRef<PyType>,
10991099
PyRwLock::new(NonNull::new_unchecked(type_type_ptr)),
11001100
);
1101-
(*type_type_ptr).refcount.incref();
1101+
(*type_type_ptr).refcount.inc();
11021102
ptr::write(
11031103
&mut (*type_type_ptr).typ as *mut PyRwLock<PyTypeRef> as *mut UninitRef<PyType>,
11041104
PyRwLock::new(NonNull::new_unchecked(type_type_ptr)),

0 commit comments

Comments
 (0)