File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,9 @@ pub trait AnyStr<'s>: 's {
145145 // FIXME: get_chars is expensive for str
146146 fn get_chars ( & self , range : std:: ops:: Range < usize > ) -> & Self ;
147147 fn bytes_len ( & self ) -> usize ;
148- fn chars_len ( & self ) -> usize ; // cannot access to cache here
148+ // NOTE: str::chars().count() consumes the O(n) time. But pystr::char_len does cache.
149+ // So using chars_len directly is too expensive and the below method shouldn't be implemented.
150+ // fn chars_len(&self) -> usize;
149151 fn is_empty ( & self ) -> bool ;
150152
151153 fn py_add ( & self , other : & Self ) -> Self :: Container {
Original file line number Diff line number Diff line change @@ -1645,10 +1645,6 @@ impl<'s> AnyStr<'s> for str {
16451645 Self :: len ( self )
16461646 }
16471647
1648- fn chars_len ( & self ) -> usize {
1649- self . chars ( ) . count ( )
1650- }
1651-
16521648 fn py_split_whitespace < F > ( & self , maxsplit : isize , convert : F ) -> Vec < PyObjectRef >
16531649 where
16541650 F : Fn ( & Self ) -> PyObjectRef ,
Original file line number Diff line number Diff line change @@ -1073,10 +1073,6 @@ impl<'s> AnyStr<'s> for [u8] {
10731073 Self :: len ( self )
10741074 }
10751075
1076- fn chars_len ( & self ) -> usize {
1077- Self :: len ( self )
1078- }
1079-
10801076 fn py_split_whitespace < F > ( & self , maxsplit : isize , convert : F ) -> Vec < PyObjectRef >
10811077 where
10821078 F : Fn ( & Self ) -> PyObjectRef ,
You can’t perform that action at this time.
0 commit comments