Skip to content

Commit

Permalink
Small opt when prune messages (paritytech#1389)
Browse files Browse the repository at this point in the history
* Small opt when prune messages

* Fix typing error
  • Loading branch information
hujw77 authored and serban300 committed Apr 10, 2024
1 parent 9e65c2b commit 52afe54
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions bridges/modules/messages/src/outbound_lane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,17 @@ impl<S: OutboundLaneStorage> OutboundLane<S> {
/// Returns number of pruned messages.
pub fn prune_messages(&mut self, max_messages_to_prune: MessageNonce) -> MessageNonce {
let mut pruned_messages = 0;
let mut anything_changed = false;
let mut data = self.storage.data();
while pruned_messages < max_messages_to_prune &&
data.oldest_unpruned_nonce <= data.latest_received_nonce
{
self.storage.remove_message(&data.oldest_unpruned_nonce);

anything_changed = true;
pruned_messages += 1;
data.oldest_unpruned_nonce += 1;
}

if anything_changed {
if pruned_messages > 0 {
self.storage.set_data(data);
}

Expand Down

0 comments on commit 52afe54

Please sign in to comment.