Skip to content

Commit b2c0fa4

Browse files
committed
Simplify SliceReader
The maximum recursion limit tracked within `decode_dag_cbor_to_pyobject()`, hence it doesn't need to be part of the SliceReader.
1 parent 828a12c commit b2c0fa4

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ mod marker {
2020
pub const F64: u8 = 0xfb;
2121
}
2222

23-
// Copy from cbor4ii/src/utils.rs.
23+
// Based on cbor4ii/src/utils.rs.
2424
/// An in-memory reader.
2525
struct SliceReader<'a> {
2626
buf: &'a [u8],
27-
limit: usize,
2827
}
2928

3029
impl SliceReader<'_> {
3130
fn new(buf: &[u8]) -> SliceReader<'_> {
32-
SliceReader { buf, limit: 256 }
31+
SliceReader { buf }
3332
}
3433
}
3534

@@ -47,21 +46,6 @@ impl<'de> dec::Read<'de> for SliceReader<'de> {
4746
let len = core::cmp::min(self.buf.len(), n);
4847
self.buf = &self.buf[len..];
4948
}
50-
51-
#[inline]
52-
fn step_in(&mut self) -> bool {
53-
if let Some(limit) = self.limit.checked_sub(1) {
54-
self.limit = limit;
55-
true
56-
} else {
57-
false
58-
}
59-
}
60-
61-
#[inline]
62-
fn step_out(&mut self) {
63-
self.limit += 1;
64-
}
6549
}
6650

6751
fn cid_hash_to_pydict<'py>(py: Python<'py>, cid: &Cid) -> Bound<'py, PyDict> {

0 commit comments

Comments
 (0)