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

Method fast_position

crates/vm/src/protocol/buffer.rs:252–262  ·  view source on GitHub ↗

this function do not check the bound panic if indices.len() != ndim

(&self, indices: &[usize])

Source from the content-addressed store, hash-verified

250 /// this function do not check the bound
251 /// panic if indices.len() != ndim
252 pub fn fast_position(&self, indices: &[usize]) -> isize {
253 let mut pos = 0;
254 for (i, (_, stride, suboffset)) in indices
255 .iter()
256 .cloned()
257 .zip_eq(self.dim_desc.iter().cloned())
258 {
259 pos += i as isize * stride + suboffset;
260 }
261 pos
262 }
263
264 /// panic if indices.len() != ndim
265 pub fn position(&self, indices: &[isize], vm: &VirtualMachine) -> PyResult<isize> {

Callers

nothing calls this directly

Calls 2

zip_eqMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected