Skip to content

Commit 6b2c94f

Browse files
authored
nit: avoid recompute quantize_up in loops (#1415)
avoid recompute quantize_up
1 parent e5b4a0c commit 6b2c94f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

actors/miner/src/expiration_queue.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {
247247
let groups = self.find_sectors_by_expiration(sector_size, sectors)?;
248248

249249
// Group sectors by their target expiration, then remove from existing queue entries according to those groups.
250+
let new_quantized_expiration = self.quant.quantize_up(new_expiration);
250251
for mut group in groups {
251-
if group.sector_epoch_set.epoch <= self.quant.quantize_up(new_expiration) {
252+
if group.sector_epoch_set.epoch <= new_quantized_expiration {
252253
// Don't reschedule sectors that are already due to expire on-time before the fault-driven expiration,
253254
// but do represent their power as now faulty.
254255
// Their pledge remains as "on-time".
@@ -297,10 +298,11 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {
297298

298299
let mut mutated_expiration_sets = Vec::<(ChainEpoch, ExpirationSet)>::new();
299300

301+
let quantized_fault_expiration = self.quant.quantize_up(fault_expiration);
300302
self.amt.for_each(|e, expiration_set| {
301303
let epoch: ChainEpoch = e.try_into()?;
302304

303-
if epoch <= self.quant.quantize_up(fault_expiration) {
305+
if epoch <= quantized_fault_expiration {
304306
let mut expiration_set = expiration_set.clone();
305307

306308
// Regardless of whether the sectors were expiring on-time or early, all the power is now faulty.

0 commit comments

Comments
 (0)