mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Deprecate AnyStr::chars_len again
I implemented 84e5f4212d6a5707748293b9603493661ac33355 again but I deprecate the method again because it is too expensive. See also https://github.com/RustPython/RustPython/pull/3164#discussion_r725438699
This commit is contained in:
@@ -145,7 +145,9 @@ pub trait AnyStr<'s>: 's {
|
||||
// FIXME: get_chars is expensive for str
|
||||
fn get_chars(&self, range: std::ops::Range<usize>) -> &Self;
|
||||
fn bytes_len(&self) -> usize;
|
||||
fn chars_len(&self) -> usize; // cannot access to cache here
|
||||
// NOTE: str::chars().count() consumes the O(n) time. But pystr::char_len does cache.
|
||||
// So using chars_len directly is too expensive and the below method shouldn't be implemented.
|
||||
// fn chars_len(&self) -> usize;
|
||||
fn is_empty(&self) -> bool;
|
||||
|
||||
fn py_add(&self, other: &Self) -> Self::Container {
|
||||
|
||||
@@ -1645,10 +1645,6 @@ impl<'s> AnyStr<'s> for str {
|
||||
Self::len(self)
|
||||
}
|
||||
|
||||
fn chars_len(&self) -> usize {
|
||||
self.chars().count()
|
||||
}
|
||||
|
||||
fn py_split_whitespace<F>(&self, maxsplit: isize, convert: F) -> Vec<PyObjectRef>
|
||||
where
|
||||
F: Fn(&Self) -> PyObjectRef,
|
||||
|
||||
@@ -1073,10 +1073,6 @@ impl<'s> AnyStr<'s> for [u8] {
|
||||
Self::len(self)
|
||||
}
|
||||
|
||||
fn chars_len(&self) -> usize {
|
||||
Self::len(self)
|
||||
}
|
||||
|
||||
fn py_split_whitespace<F>(&self, maxsplit: isize, convert: F) -> Vec<PyObjectRef>
|
||||
where
|
||||
F: Fn(&Self) -> PyObjectRef,
|
||||
|
||||
Reference in New Issue
Block a user