Skip to content

Commit 4add022

Browse files
committed
PyValue::class() returns ref
1 parent 34a2038 commit 4add022

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+263
-254
lines changed

vm/src/builtins/asyncgenerator.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub struct PyAsyncGen {
2020
type PyAsyncGenRef = PyRef<PyAsyncGen>;
2121

2222
impl PyValue for PyAsyncGen {
23-
fn class(vm: &VirtualMachine) -> PyTypeRef {
24-
vm.ctx.types.async_generator.clone()
23+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
24+
&vm.ctx.types.async_generator
2525
}
2626
}
2727

@@ -118,8 +118,8 @@ impl PyAsyncGen {
118118
#[derive(Debug)]
119119
pub(crate) struct PyAsyncGenWrappedValue(pub PyObjectRef);
120120
impl PyValue for PyAsyncGenWrappedValue {
121-
fn class(vm: &VirtualMachine) -> PyTypeRef {
122-
vm.ctx.types.async_generator_wrapped_value.clone()
121+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
122+
&vm.ctx.types.async_generator_wrapped_value
123123
}
124124
}
125125

@@ -167,8 +167,8 @@ pub(crate) struct PyAsyncGenASend {
167167
}
168168

169169
impl PyValue for PyAsyncGenASend {
170-
fn class(vm: &VirtualMachine) -> PyTypeRef {
171-
vm.ctx.types.async_generator_asend.clone()
170+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
171+
&vm.ctx.types.async_generator_asend
172172
}
173173
}
174174

@@ -263,8 +263,8 @@ pub(crate) struct PyAsyncGenAThrow {
263263
}
264264

265265
impl PyValue for PyAsyncGenAThrow {
266-
fn class(vm: &VirtualMachine) -> PyTypeRef {
267-
vm.ctx.types.async_generator_athrow.clone()
266+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
267+
&vm.ctx.types.async_generator_athrow
268268
}
269269
}
270270

vm/src/builtins/builtinfunc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ pub struct PyBuiltinFunction {
6363
}
6464

6565
impl PyValue for PyBuiltinFunction {
66-
fn class(vm: &VirtualMachine) -> PyTypeRef {
67-
vm.ctx.types.builtin_function_or_method_type.clone()
66+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
67+
&vm.ctx.types.builtin_function_or_method_type
6868
}
6969
}
7070

@@ -139,8 +139,8 @@ pub struct PyBuiltinMethod {
139139
}
140140

141141
impl PyValue for PyBuiltinMethod {
142-
fn class(vm: &VirtualMachine) -> PyTypeRef {
143-
vm.ctx.types.method_descriptor_type.clone()
142+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
143+
&vm.ctx.types.method_descriptor_type
144144
}
145145
}
146146

vm/src/builtins/bytearray.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ impl From<Vec<u8>> for PyByteArray {
8383
}
8484

8585
impl PyValue for PyByteArray {
86-
fn class(vm: &VirtualMachine) -> PyTypeRef {
87-
vm.ctx.types.bytearray_type.clone()
86+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
87+
&vm.ctx.types.bytearray_type
8888
}
8989
}
9090

@@ -562,7 +562,7 @@ impl PyByteArray {
562562
fn reduce(zelf: PyRef<Self>, vm: &VirtualMachine) -> (PyTypeRef, PyTupleRef) {
563563
let bytes = PyBytes::from(zelf.borrow_value().elements.clone()).into_pyobject(vm);
564564
(
565-
Self::class(vm),
565+
Self::class(vm).clone(),
566566
PyTupleRef::with_elements(vec![bytes], &vm.ctx),
567567
)
568568
}
@@ -650,8 +650,8 @@ pub struct PyByteArrayIterator {
650650
}
651651

652652
impl PyValue for PyByteArrayIterator {
653-
fn class(vm: &VirtualMachine) -> PyTypeRef {
654-
vm.ctx.types.bytearray_iterator_type.clone()
653+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
654+
&vm.ctx.types.bytearray_iterator_type
655655
}
656656
}
657657

vm/src/builtins/bytes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ impl Deref for PyBytes {
8989
}
9090

9191
impl PyValue for PyBytes {
92-
fn class(vm: &VirtualMachine) -> PyTypeRef {
93-
vm.ctx.types.bytes_type.clone()
92+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
93+
&vm.ctx.types.bytes_type
9494
}
9595
}
9696

@@ -537,8 +537,8 @@ pub struct PyBytesIterator {
537537
}
538538

539539
impl PyValue for PyBytesIterator {
540-
fn class(vm: &VirtualMachine) -> PyTypeRef {
541-
vm.ctx.types.bytes_iterator_type.clone()
540+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
541+
&vm.ctx.types.bytes_iterator_type
542542
}
543543
}
544544

vm/src/builtins/classmethod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ impl From<PyObjectRef> for PyClassMethod {
3838
}
3939

4040
impl PyValue for PyClassMethod {
41-
fn class(vm: &VirtualMachine) -> PyTypeRef {
42-
vm.ctx.types.classmethod_type.clone()
41+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
42+
&vm.ctx.types.classmethod_type
4343
}
4444
}
4545

vm/src/builtins/code.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ impl fmt::Debug for PyCode {
3737
}
3838

3939
impl PyValue for PyCode {
40-
fn class(vm: &VirtualMachine) -> PyTypeRef {
41-
vm.ctx.types.code_type.clone()
40+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
41+
&vm.ctx.types.code_type
4242
}
4343
}
4444

vm/src/builtins/complex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub struct PyComplex {
2222
}
2323

2424
impl PyValue for PyComplex {
25-
fn class(vm: &VirtualMachine) -> PyTypeRef {
26-
vm.ctx.types.complex_type.clone()
25+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
26+
&vm.ctx.types.complex_type
2727
}
2828
}
2929

vm/src/builtins/coroutine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub struct PyCoroutine {
1616
}
1717

1818
impl PyValue for PyCoroutine {
19-
fn class(vm: &VirtualMachine) -> PyTypeRef {
20-
vm.ctx.types.coroutine_type.clone()
19+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
20+
&vm.ctx.types.coroutine_type
2121
}
2222
}
2323

@@ -102,8 +102,8 @@ pub struct PyCoroutineWrapper {
102102
}
103103

104104
impl PyValue for PyCoroutineWrapper {
105-
fn class(vm: &VirtualMachine) -> PyTypeRef {
106-
vm.ctx.types.coroutine_wrapper_type.clone()
105+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
106+
&vm.ctx.types.coroutine_wrapper_type
107107
}
108108
}
109109

vm/src/builtins/dict.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ impl fmt::Debug for PyDict {
4343
}
4444

4545
impl PyValue for PyDict {
46-
fn class(vm: &VirtualMachine) -> PyTypeRef {
47-
vm.ctx.types.dict_type.clone()
46+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
47+
&vm.ctx.types.dict_type
4848
}
4949
}
5050

@@ -645,8 +645,8 @@ macro_rules! dict_iterator {
645645
}
646646

647647
impl PyValue for $name {
648-
fn class(vm: &VirtualMachine) -> PyTypeRef {
649-
vm.ctx.types.$class.clone()
648+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
649+
&vm.ctx.types.$class
650650
}
651651
}
652652

@@ -698,8 +698,8 @@ macro_rules! dict_iterator {
698698
}
699699

700700
impl PyValue for $iter_name {
701-
fn class(vm: &VirtualMachine) -> PyTypeRef {
702-
vm.ctx.types.$iter_class.clone()
701+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
702+
&vm.ctx.types.$iter_class
703703
}
704704
}
705705

@@ -754,8 +754,8 @@ macro_rules! dict_iterator {
754754
}
755755

756756
impl PyValue for $reverse_iter_name {
757-
fn class(vm: &VirtualMachine) -> PyTypeRef {
758-
vm.ctx.types.$reverse_iter_class.clone()
757+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
758+
&vm.ctx.types.$reverse_iter_class
759759
}
760760
}
761761
};

vm/src/builtins/enumerate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub struct PyEnumerate {
1919
}
2020

2121
impl PyValue for PyEnumerate {
22-
fn class(vm: &VirtualMachine) -> PyTypeRef {
23-
vm.ctx.types.enumerate_type.clone()
22+
fn class(vm: &VirtualMachine) -> &PyTypeRef {
23+
&vm.ctx.types.enumerate_type
2424
}
2525
}
2626

0 commit comments

Comments
 (0)