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

Method irepeat

crates/vm/src/builtins/bytearray.rs:152–169  ·  view source on GitHub ↗
(zelf: &Py<Self>, n: isize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

150 }
151
152 fn irepeat(zelf: &Py<Self>, n: isize, vm: &VirtualMachine) -> PyResult<()> {
153 if n == 1 {
154 return Ok(());
155 }
156 let mut w = match zelf.try_resizable(vm) {
157 Ok(w) => w,
158 Err(err) => {
159 return if zelf.borrow_buf().is_empty() {
160 // We can multiple an empty vector by any integer
161 Ok(())
162 } else {
163 Err(err)
164 };
165 }
166 };
167
168 w.imul(n, vm)
169 }
170}
171
172#[pyclass(

Callers

nothing calls this directly

Calls 5

try_resizableMethod · 0.80
ErrClass · 0.50
is_emptyMethod · 0.45
borrow_bufMethod · 0.45
imulMethod · 0.45

Tested by

no test coverage detected