Skip to content

Commit f78e3a4

Browse files
committed
optimize iterator construction
Signed-off-by: Jason Volk <[email protected]>
1 parent c4e8fb8 commit f78e3a4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/db_iterator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ impl<'a, D: DBAccess> DBRawIteratorWithThreadMode<'a, D> {
107107
}
108108

109109
fn from_inner(inner: *mut ffi::rocksdb_iterator_t, readopts: ReadOptions) -> Self {
110-
// This unwrap will never fail since rocksdb_create_iterator and
110+
// SAFETY: This unwrap will never fail since rocksdb_create_iterator and
111111
// rocksdb_create_iterator_cf functions always return non-null. They
112112
// use new and deference the result so any nulls would end up with SIGSEGV
113113
// there and we would have a bigger issue.
114-
let inner = std::ptr::NonNull::new(inner).unwrap();
114+
unsafe { std::hint::assert_unchecked(!inner.is_null()) };
115115
Self {
116-
inner,
116+
inner: std::ptr::NonNull::new(inner).unwrap(),
117117
_readopts: readopts,
118118
db: PhantomData,
119119
}

0 commit comments

Comments
 (0)