GeezerVison is showing github.com — Remove unused _membership_iter_search (#6318) · RustPython/RustPython@bf8152b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: crates/vm/src/builtins/range.rs -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -28,8 +28,6 @@ enum SearchType { | 28 | 28 | Index, | 29 | 29 | } | 30 | 30 |
| 31 | | -// Note: might be a good idea to merge with _membership_iter_search or generalize (_sequence_iter_check?) | 32 | | -// and place in vm.rs for all sequences to be able to use it. | 33 | 31 | #[inline] | 34 | 32 | fn iter_search( | 35 | 33 | obj: &PyObject, | |
Collapse file Copy file name to clipboardExpand all lines: crates/vm/src/vm/vm_ops.rs +2-22Lines changed: 2 additions & 22 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,9 +2,9 @@ use super::VirtualMachine; | 2 | 2 | use crate::stdlib::warnings; | 3 | 3 | use crate::{ | 4 | 4 | PyRef, | 5 | | - builtins::{PyInt, PyIntRef, PyStr, PyStrRef, PyUtf8Str}, | | 5 | + builtins::{PyInt, PyStr, PyStrRef, PyUtf8Str}, | 6 | 6 | object::{AsObject, PyObject, PyObjectRef, PyResult}, | 7 | | - protocol::{PyIterReturn, PyNumberBinaryOp, PyNumberTernaryOp, PySequence}, | | 7 | + protocol::{PyNumberBinaryOp, PyNumberTernaryOp, PySequence}, | 8 | 8 | types::PyComparisonOp, | 9 | 9 | }; | 10 | 10 | use num_traits::ToPrimitive; | @@ -529,26 +529,6 @@ impl VirtualMachine { | 529 | 529 | self.format(obj, format_spec)?.try_into_utf8(self) | 530 | 530 | } | 531 | 531 |
| 532 | | - // https://docs.python.org/3/reference/expressions.html#membership-test-operations | 533 | | - fn _membership_iter_search( | 534 | | - &self, | 535 | | - haystack: &PyObject, | 536 | | - needle: PyObjectRef, | 537 | | - ) -> PyResult<PyIntRef> { | 538 | | - let iter = haystack.get_iter(self)?; | 539 | | - loop { | 540 | | - if let PyIterReturn::Return(element) = iter.next(self)? { | 541 | | - if self.bool_eq(&element, &needle)? { | 542 | | - return Ok(self.ctx.new_bool(true)); | 543 | | - } else { | 544 | | - continue; | 545 | | - } | 546 | | - } else { | 547 | | - return Ok(self.ctx.new_bool(false)); | 548 | | - } | 549 | | - } | 550 | | - } | 551 | | - | 552 | 532 | pub fn _contains(&self, haystack: &PyObject, needle: &PyObject) -> PyResult<bool> { | 553 | 533 | let seq = haystack.to_sequence(); | 554 | 534 | seq.contains(needle, self) | |
|