8000 sequence comparison uses `impl SimpleSeq` rather than `dyn SimpleSeq` · RustPython/RustPython@db0089e · GitHub
[go: up one dir, main page]

Skip to content

Commit db0089e

Browse files
committed
sequence comparison uses impl SimpleSeq rather than dyn SimpleSeq
1 parent 1272887 commit db0089e

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

vm/src/obj/objsequence.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ impl SimpleSeq for std::collections::VecDeque<PyObjectRef> {
277277

278278
pub fn seq_equal(
279279
vm: &VirtualMachine,
280-
zelf: &dyn SimpleSeq,
281-
other: &dyn SimpleSeq,
280+
zelf: &impl SimpleSeq,
281+
other: &impl SimpleSeq,
282282
) -> PyResult<bool> {
283283
if zelf.len() == other.len() {
284284
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
@@ -295,7 +295,11 @@ pub fn seq_equal(
295295
}
296296
}
297297

298-
pub fn seq_lt(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq) -> PyResult<bool> {
298+
pub fn seq_lt(
299+
vm: &VirtualMachine,
300+
zelf: &impl SimpleSeq,
301+
other: &impl SimpleSeq,
302+
) -> PyResult<bool> {
299303
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
300304
if let Some(v) = vm.bool_seq_lt(a.clone(), b.clone())? {
301305
return Ok(v);
@@ -304,7 +308,11 @@ pub fn seq_lt(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq)
304308
Ok(zelf.len() < other.len())
305309
}
306310

307-
pub fn seq_gt(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq) -> PyResult<bool> {
311+
pub fn seq_gt(
312+
vm: &VirtualMachine,
313+
zelf: &impl SimpleSeq,
314+
other: &impl SimpleSeq,
315+
) -> PyResult<bool> {
308316
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
309317
if let Some(v) = vm.bool_seq_gt(a.clone(), b.clone())? {
310318
return Ok(v);
@@ -313,7 +321,11 @@ pub fn seq_gt(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq)
313321
Ok(zelf.len() > other.len())
314322
}
315323

316-
pub fn seq_ge(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq) -> PyResult<bool> {
324+
pub fn seq_ge(
325+
vm: &VirtualMachine,
326+
zelf: &impl SimpleSeq,
327+
other: &impl SimpleSeq,
328+
) -> PyResult<bool> {
317329
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
318330
if let Some(v) = vm.bool_seq_gt(a.clone(), b.clone())? {
319331
return Ok(v);
@@ -323,7 +335,11 @@ pub fn seq_ge(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq)
323335
Ok(zelf.len() >= other.len())
324336
}
325337

326-
pub fn seq_le(vm: &VirtualMachine, zelf: &dyn SimpleSeq, other: &dyn SimpleSeq) -> PyResult<bool> {
338+
pub fn seq_le(
339+
vm: &VirtualMachine,
340+
zelf: &impl SimpleSeq,
341+
other: &impl SimpleSeq,
342+
) -> PyResult<bool> {
327343
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
328344
if let Some(v) = vm.bool_seq_lt(a.clone(), b.clone())? {
329345
return Ok(v);
@@ -365,7 +381,7 @@ impl<'a> Iterator for SeqMul<'a> {
365381
}
366382
impl ExactSizeIterator for SeqMul<'_> {}
367383

368-
pub fn seq_mul(seq: &dyn SimpleSeq, repetitions: isize) -> SeqMul {
384+
pub fn seq_mul(seq: &impl SimpleSeq, repetitions: isize) -> SeqMul {
369385
SeqMul {
370386
seq,
371387
repetitions: repetitions.max(0) as usize,

vm/src/obj/objtuple.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ impl PyTuple {
189189

190190
#[pymethod(name = "__mul__")]
191191
fn mul(&self, counter: isize, vm: &VirtualMachine) -> PyObjectRef {
192-
let new_elements = seq_mul(&self.as_slice(), counter)
193-
.cloned()
194-
.collect();
192+
let new_elements = seq_mul(&self.as_slice(), counter).cloned().collect();
195193
vm.ctx.new_tuple(new_elements)
196194
}
197195

0 commit comments

Comments
 (0)
0