Return early if no prune deletions
This change updates the prune_entries function to return early if there
are no deletions to be made.  This saves the update of a change log that
is unnecessary.
@@ -50,6 +50,10 @@ impl<'a> MerkleRadixPruneEntriesOperation for MerkleRadixOperations<'a, SqliteCo
let Candidates { deletions, .. } =
get_deletion_candidates(self.conn, tree_id, state_root)?;
+ if deletions.is_empty() {
+ return Ok(vec![]);
+ }
+
update_changelogs(self.conn, tree_id, state_root, SQLITE_NOW_MILLIS)?;
let mut deleted_values = vec![];
@@ -95,6 +99,10 @@ impl<'a> MerkleRadixPruneEntriesOperation for MerkleRadixOperations<'a, PgConnec
let Candidates { deletions, .. } =
get_deletion_candidates(self.conn, tree_id, state_root)?;
+ if deletions.is_empty() {
+ return Ok(vec![]);
+ }
+
update_changelogs(self.conn, tree_id, state_root, POSTGRES_NOW_MILLIS)?;
let mut deleted_values = vec![];
