Remove unused _membership_iter_search (#6318)

This commit is contained in:
Jeong, YunWon
2025-12-02 10:11:04 +09:00
committed by GitHub
parent 9130dd8068
commit bf8152b4b8
2 changed files with 2 additions and 24 deletions

View File

@@ -28,8 +28,6 @@ enum SearchType {
Index,
}
// Note: might be a good idea to merge with _membership_iter_search or generalize (_sequence_iter_check?)
// and place in vm.rs for all sequences to be able to use it.
#[inline]
fn iter_search(
obj: &PyObject,

View File

@@ -2,9 +2,9 @@ use super::VirtualMachine;
use crate::stdlib::warnings;
use crate::{
PyRef,
builtins::{PyInt, PyIntRef, PyStr, PyStrRef, PyUtf8Str},
builtins::{PyInt, PyStr, PyStrRef, PyUtf8Str},
object::{AsObject, PyObject, PyObjectRef, PyResult},
protocol::{PyIterReturn, PyNumberBinaryOp, PyNumberTernaryOp, PySequence},
protocol::{PyNumberBinaryOp, PyNumberTernaryOp, PySequence},
types::PyComparisonOp,
};
use num_traits::ToPrimitive;
@@ -529,26 +529,6 @@ impl VirtualMachine {
self.format(obj, format_spec)?.try_into_utf8(self)
}
// https://docs.python.org/3/reference/expressions.html#membership-test-operations
fn _membership_iter_search(
&self,
haystack: &PyObject,
needle: PyObjectRef,
) -> PyResult<PyIntRef> {
let iter = haystack.get_iter(self)?;
loop {
if let PyIterReturn::Return(element) = iter.next(self)? {
if self.bool_eq(&element, &needle)? {
return Ok(self.ctx.new_bool(true));
} else {
continue;
}
} else {
return Ok(self.ctx.new_bool(false));
}
}
}
pub fn _contains(&self, haystack: &PyObject, needle: &PyObject) -> PyResult<bool> {
let seq = haystack.to_sequence();
seq.contains(needle, self)