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

Method do_delete_indexes

crates/vm/src/sliceable.rs:142–160  ·  view source on GitHub ↗
(&mut self, range: Range<usize>, indexes: I)

Source from the content-addressed store, hash-verified

140 }
141
142 fn do_delete_indexes<I>(&mut self, range: Range<usize>, indexes: I)
143 where
144 I: Iterator<Item = usize>,
145 {
146 let mut indexes = indexes.peekable();
147 let mut deleted = 0;
148
149 // passing whole range, swap or overlap
150 for i in range.clone() {
151 if indexes.peek() == Some(&i) {
152 indexes.next();
153 deleted += 1;
154 } else {
155 self.swap(i - deleted, i);
156 }
157 }
158 // then drain (the values to delete should now be contiguous at the end of the range)
159 self.drain((range.end - deleted)..range.end);
160 }
161}
162
163#[allow(clippy::len_without_is_empty)]

Callers 1

delitem_by_sliceMethod · 0.80

Calls 6

SomeClass · 0.50
cloneMethod · 0.45
peekMethod · 0.45
nextMethod · 0.45
swapMethod · 0.45
drainMethod · 0.45

Tested by

no test coverage detected