Skip to content

Commit 321ed2d

Browse files
committed
Remove magic constant
1 parent 1e21267 commit 321ed2d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<const MAX_DOC_PER_PAGE: u32, const PAGE_SIZE: u64, DocId: DocumentId>
127127
got: document_count,
128128
});
129129
}
130-
if docs.len() == 0 {
130+
if docs.is_empty() {
131131
return Err(ZeboError::NoDocToAdd);
132132
}
133133

src/page.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{fs::File, io::Write, os::unix::fs::FileExt};
22

3-
use tracing::{debug, error, instrument};
3+
use tracing::{debug, error, instrument, trace};
44

55
use crate::{Document, DocumentId, Result, Version, ZeboError, index::ProbableIndex};
66

@@ -241,6 +241,8 @@ impl ZeboPage {
241241
&self,
242242
doc_id_with_index: &[(u64, ProbableIndex)],
243243
) -> Result<Vec<(DocId, Vec<u8>)>> {
244+
trace!("Getting documents: {:?}", doc_id_with_index);
245+
244246
let mut r = Vec::with_capacity(doc_id_with_index.len());
245247

246248
for (doc_id, probable_index) in doc_id_with_index {
@@ -730,7 +732,8 @@ impl ZeboPage {
730732

731733
fn find_from_start(&self, target_doc_id: u64) -> Result<Option<(u64, u32, u32)>> {
732734
let mut buf = [0; 16];
733-
for i in 0..=1179623 {
735+
let mut i = 0;
736+
loop {
734737
match self
735738
.page_file
736739
.read_exact_at(&mut buf, DOCUMENT_INDEX_OFFSET + (i * (4 + 4 + 8)))
@@ -759,6 +762,7 @@ impl ZeboPage {
759762
return Err(ZeboError::OperationError(e));
760763
}
761764
}
765+
i += 1;
762766
}
763767

764768
Ok(None)

0 commit comments

Comments
 (0)