Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: improve readability #23

Merged
merged 10 commits into from
Nov 21, 2023
Prev Previous commit
Next Next commit
refactor: avoid reading storage size multiple times
arindas committed Oct 9, 2023
commit b7c167dcb9f2d504b936057b0b6c3c928c5624fc
8 changes: 3 additions & 5 deletions src/storage/commit_log/segmented_log/index.rs
Original file line number Diff line number Diff line change
@@ -258,9 +258,9 @@ where
) -> Result<Vec<IndexRecord>, IndexError<S::Error>> {
let mut position = INDEX_BASE_MARKER_LENGTH as u64;

let mut index_records = Vec::<IndexRecord>::with_capacity(
Self::estimated_index_records_len_in_storage(storage)?,
);
let estimated_index_records_len = Self::estimated_index_records_len_in_storage(storage)?;

let mut index_records = Vec::<IndexRecord>::with_capacity(estimated_index_records_len);

while let Ok(index_record) =
PersistentSizedRecord::<IndexRecord, INDEX_RECORD_LENGTH>::read_at(
@@ -275,8 +275,6 @@ where

index_records.shrink_to_fit();

let estimated_index_records_len = Self::estimated_index_records_len_in_storage(storage)?;

if index_records.len() != estimated_index_records_len {
Err(IndexError::InconsistentIndexSize)
} else {