MCPcopy Index your code
hub / github.com/RustPython/RustPython / _compute_char_len

Method _compute_char_len

crates/common/src/str.rs:310–320  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

308
309 #[cold]
310 fn _compute_char_len(&self) -> usize {
311 let len = if let Some(s) = self.as_str() {
312 // utf8 chars().count() is optimized
313 s.chars().count()
314 } else {
315 self.data.code_points().count()
316 };
317 // len cannot be usize::MAX, since vec.capacity() < sys.maxsize
318 self.len.0.store(len, Relaxed);
319 len
320 }
321
322 pub fn nth_char(&self, index: usize) -> CodePoint {
323 match self.as_str_kind() {

Callers 1

char_lenMethod · 0.80

Calls 5

charsMethod · 0.80
code_pointsMethod · 0.80
as_strMethod · 0.45
countMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected