Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
qingshi163 committed Nov 22, 2021
commit d8d9113d6286e9315023c9a254036a321b4760aa
1 change: 0 additions & 1 deletion vm/src/builtins/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ impl Comparable for PyList {
let other = class_or_notimplemented!(Self, other);
let a = &*zelf.borrow_vec();
let b = &*other.borrow_vec();
// sequence::cmp(vm, a.boxed_iter(), b.boxed_iter(), op).map(PyComparisonValue::Implemented)
a.cmp(vm, b, op).map(PyComparisonValue::Implemented)
}
}
Expand Down
1 change: 1 addition & 0 deletions vm/src/builtins/pystr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ impl PyStr {
return Ok(zelf);
}
zelf.as_str()
.as_bytes()
.mul(vm, value)
.map(|x| Self::from(unsafe { String::from_utf8_unchecked(x) }).into_ref(vm))
}
Expand Down
25 changes: 10 additions & 15 deletions vm/src/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ use crate::{

pub trait ObjectSequenceOp<'a> {
type Iter: ExactSizeIterator<Item = &'a PyObjectRef>;

fn iter(&'a self) -> Self::Iter;

fn eq(&'a self, vm: &VirtualMachine, other: &'a Self) -> PyResult<bool> {
let lhs = self.iter();
let rhs = other.iter();
if lhs.len() == rhs.len() {
for (a, b) in lhs.zip_eq(rhs) {
if !vm.identical_or_equal(a, b)? {
return Ok(false);
}
if lhs.len() != rhs.len() {
return Ok(false);
}
for (a, b) in lhs.zip_eq(rhs) {
if !vm.identical_or_equal(a, b)? {
return Ok(false);
}
Ok(true)
} else {
Ok(false)
}
Ok(true)
}

fn cmp(&'a self, vm: &VirtualMachine, other: &'a Self, op: PyComparisonOp) -> PyResult<bool> {
Expand Down Expand Up @@ -71,6 +72,7 @@ impl<'a> ObjectSequenceOp<'a> for VecDeque<PyObjectRef> {

pub trait MutObjectSequenceOp<'a> {
type Guard;

fn do_get(index: usize, guard: &Self::Guard) -> Option<&PyObjectRef>;
fn do_lock(&'a self) -> Self::Guard;

Expand Down Expand Up @@ -99,7 +101,6 @@ pub trait MutObjectSequenceOp<'a> {
self.mut_index(vm, needle).map(|x| x.is_some())
}

#[inline]
fn _mut_iter_equal_skeleton<F, const SHORT: bool>(
&'a self,
vm: &VirtualMachine,
Expand Down Expand Up @@ -260,12 +261,6 @@ impl<T: Clone> SequenceOp<T> for [T] {
}
}

impl SequenceOp<u8> for &str {
fn as_slice(&self) -> &[u8] {
self.as_bytes()
}
}

pub trait SequenceMutOp<T: Clone> {
fn as_slice(&self) -> &[T];
fn as_vec_mut(&mut self) -> &mut Vec<T>;
Expand Down