Skip to content

Commit 5dcc814

Browse files
committed
Replace PyObject::new by into_simple_object
1 parent cbaa7e1 commit 5dcc814

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

vm/src/stdlib/array.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::obj::objtype::PyClassRef;
1111
use crate::obj::{objbool, objiter};
1212
use crate::pyobject::{
1313
BorrowValue, Either, IdProtocol, IntoPyObject, PyArithmaticValue, PyClassImpl,
14-
PyComparisonValue, PyIterable, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
14+
PyComparisonValue, PyIterable, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
1515
TypeProtocol,
1616
};
1717
use crate::VirtualMachine;
@@ -203,13 +203,10 @@ macro_rules! def_array_enum {
203203
$(ArrayContentType::$n(v) => {
204204
let elements = v.get_slice_items(vm, &slice)?;
205205
let sliced = ArrayContentType::$n(elements);
206-
let obj = PyObject::new(
207-
PyArray {
208-
array: PyRwLock::new(sliced)
209-
},
210-
PyArray::class(vm),
211-
None
212-
);
206+
let obj = PyArray {
207+
array: PyRwLock::new(sliced)
208+
}
209+
.into_simple_object(vm);
213210
Ok(obj)
214211
})*
215212
}
@@ -340,13 +337,10 @@ macro_rules! def_array_enum {
340337
$(ArrayContentType::$n(v) => if let ArrayContentType::$n(other) = other {
341338
let elements = v.iter().chain(other.iter()).cloned().collect();
342339
let sliced = ArrayContentType::$n(elements);
343-
let obj = PyObject::new(
344-
PyArray {
345-
array: PyRwLock::new(sliced)
346-
},
347-
PyArray::class(vm),
348-
None
349-
);
340+
let obj = PyArray {
341+
array: PyRwLock::new(sliced)
342+
}
343+
.into_simple_object(vm);
350344
Ok(obj)
351345
} else {
352346
Err(vm.new_type_error("bad argument type for built-in operation".to_owned()))
@@ -371,13 +365,10 @@ macro_rules! def_array_enum {
371365
$(ArrayContentType::$n(v) => {
372366
let elements = v.iter().cycle().take(v.len() * counter).cloned().collect();
373367
let sliced = ArrayContentType::$n(elements);
374-
PyObject::new(
375-
PyArray {
376-
array: PyRwLock::new(sliced)
377-
},
378-
PyArray::class(vm),
379-
None
380-
)
368+
PyArray {
369+
array: PyRwLock::new(sliced)
370+
}
371+
.into_simple_object(vm)
381372
})*
382373
}
383374
}

0 commit comments

Comments
 (0)