Skip to content

Commit e6b6531

Browse files
authored
[refactor] More fetch_hot simplification (#793)
* [refactor] Simplify `fetch_hot` further * Update comment
1 parent db9d4f8 commit e6b6531

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/function/fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ where
7777

7878
let shallow_update = self.shallow_verify_memo(zalsa, database_key_index, memo)?;
7979

80-
if self.validate_may_be_provisional(db, zalsa, database_key_index, memo) {
80+
if !memo.may_be_provisional() {
8181
self.update_shallow(db, zalsa, database_key_index, memo, shallow_update);
8282

8383
// SAFETY: memo is present in memo_map and we have verified that it is

src/function/maybe_changed_after.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ where
6767

6868
if let Some(shallow_update) = self.shallow_verify_memo(zalsa, database_key_index, memo)
6969
{
70-
if self.validate_may_be_provisional(db, zalsa, database_key_index, memo) {
70+
if !memo.may_be_provisional() {
7171
self.update_shallow(db, zalsa, database_key_index, memo, shallow_update);
7272

7373
return if memo.revisions.changed_at > revision {
@@ -236,9 +236,11 @@ where
236236
}
237237
}
238238

239-
/// Validates this memo if it is a provisional memo. Returns true for non provisional memos or
240-
/// if the provisional memo has been successfully marked as verified final, that is, its
241-
/// cycle heads have all been finalized.
239+
/// Validates this memo if it is a provisional memo. Returns true for:
240+
/// * non provisional memos
241+
/// * provisional memos that have been successfully marked as verified final, that is, its
242+
/// cycle heads have all been finalized.
243+
/// * provisional memos that have been created in the same revision and iteration and are part of the same cycle.
242244
#[inline]
243245
pub(super) fn validate_may_be_provisional(
244246
&self,
@@ -247,9 +249,9 @@ where
247249
database_key_index: DatabaseKeyIndex,
248250
memo: &Memo<C::Output<'_>>,
249251
) -> bool {
250-
// Wouldn't it be nice if rust had an implication operator ...
251-
// may_be_provisional -> validate_provisional
252-
!memo.may_be_provisional() || self.validate_provisional(db, zalsa, database_key_index, memo)
252+
!memo.may_be_provisional()
253+
|| self.validate_provisional(db, zalsa, database_key_index, memo)
254+
|| self.validate_same_iteration(db, database_key_index, memo)
253255
}
254256

255257
/// Check if this memo's cycle heads have all been finalized. If so, mark it verified final and
@@ -353,9 +355,7 @@ where
353355
let shallow_update = self.shallow_verify_memo(zalsa, database_key_index, old_memo);
354356
let shallow_update_possible = shallow_update.is_some();
355357
if let Some(shallow_update) = shallow_update {
356-
if self.validate_may_be_provisional(db, zalsa, database_key_index, old_memo)
357-
|| self.validate_same_iteration(db, database_key_index, old_memo)
358-
{
358+
if self.validate_may_be_provisional(db, zalsa, database_key_index, old_memo) {
359359
self.update_shallow(db, zalsa, database_key_index, old_memo, shallow_update);
360360

361361
return VerifyResult::unchanged();

0 commit comments

Comments
 (0)