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

Method unchecked_push

crates/vm/src/dict_inner.rs:205–233  ·  view source on GitHub ↗
(
        &mut self,
        index: IndexIndex,
        hash_value: HashValue,
        key: PyObjectRef,
        value: T,
        index_entry: IndexEntry,
    )

Source from the content-addressed store, hash-verified

203 }
204
205 fn unchecked_push(
206 &mut self,
207 index: IndexIndex,
208 hash_value: HashValue,
209 key: PyObjectRef,
210 value: T,
211 index_entry: IndexEntry,
212 ) {
213 let entry = DictEntry {
214 hash: hash_value,
215 key,
216 value,
217 index,
218 };
219 let entry_index = self.entries.len();
220 self.entries.push(Some(entry));
221 self.indices[index] = unsafe {
222 // SAFETY: entry_index is self.entries.len(). it never can
223 // grow to `usize-2` because hash tables cannot full its index
224 IndexEntry::from_index_unchecked(entry_index)
225 };
226 self.used += 1;
227 if let IndexEntry::FREE = index_entry {
228 self.filled += 1;
229 if let Some(new_size) = self.should_resize() {
230 self.resize(new_size)
231 }
232 }
233 }
234
235 const fn size(&self) -> DictSize {
236 DictSize {

Callers 4

insertMethod · 0.80
delete_or_insertMethod · 0.80
setdefaultMethod · 0.80
setdefault_entryMethod · 0.80

Calls 5

should_resizeMethod · 0.80
SomeClass · 0.50
lenMethod · 0.45
pushMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected