optimize journal resolution code

We have the journals tracked in a HashSet, so, use the hashing
properties instead of an O(N) search.
This commit is contained in:
bunnie 2022-03-29 16:39:54 +08:00
parent 0bdf21b3ac
commit 4f1f4a3907

View file

@ -451,15 +451,13 @@ impl PddbOs {
/// Pages drawn from disk might already have come from the FSCB. We need to make the journal number /// Pages drawn from disk might already have come from the FSCB. We need to make the journal number
/// of these consistent with those in the FSCB so later on when they are retired we don't have journal conflicts. /// of these consistent with those in the FSCB so later on when they are retired we don't have journal conflicts.
fn resolve_pp_journal(&self, pp: &mut PhysPage) { fn resolve_pp_journal(&self, pp: &mut PhysPage) {
for fs_pp in self.fspace_cache.iter() { if let Some(fs_pp) = self.fspace_cache.get(pp) {
if pp.page_number() == fs_pp.page_number() {
if pp.journal() < fs_pp.journal() { if pp.journal() < fs_pp.journal() {
log::debug!("bumping journal {}->{}: {:x?}", pp.journal(), fs_pp.journal(), pp); log::debug!("bumping journal {}->{}: {:x?}", pp.journal(), fs_pp.journal(), pp);
pp.set_journal(fs_pp.journal()); pp.set_journal(fs_pp.journal());
} }
} }
} }
}
/// maps a StaticCryptoData structure into the key area of the PDDB. /// maps a StaticCryptoData structure into the key area of the PDDB.
fn static_crypto_data_get(&self) -> &StaticCryptoData { fn static_crypto_data_get(&self) -> &StaticCryptoData {