Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn sort_map_keys(keys: &Bound<PyList>, len: usize) -> Result<Vec<(PyBackedStr, u
// Returns key and index.
let mut keys_str = Vec::with_capacity(len);
for i in 0..len {
let item = keys.get_item(i)?;
let item = unsafe { keys.get_item_unchecked(i) };
let key = match item.cast::<PyString>() {
Ok(k) => k.to_owned(),
Err(_) => return Err(anyhow!("Map keys must be strings")),
Expand Down Expand Up @@ -354,7 +354,8 @@ where
types::Array::bounded(len, w)?;

for i in 0..len {
encode_dag_cbor_from_pyobject(_py, &l.get_item(i)?, w)?;
let item = unsafe { l.get_item_unchecked(i) };
encode_dag_cbor_from_pyobject(_py, &item, w)?;
}

Ok(())
Expand All @@ -369,7 +370,8 @@ where
key.get(..)
.expect("whole range is a valid string")
.encode(w)?;
encode_dag_cbor_from_pyobject(_py, &values.get_item(i)?, w)?;
let value = unsafe { values.get_item_unchecked(i) };
encode_dag_cbor_from_pyobject(_py, &value, w)?;
}

Ok(())
Expand Down
Loading