Skip to content

Commit 22c5151

Browse files
authored
Merge pull request #5695 from stacks-network/fix/clippy-ci-unnecessary-lazy-evaluations
Fix clippy::unnecessary_lazy_evaluations throughout stacks core
2 parents 039c155 + ed29147 commit 22c5151

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

stackslib/src/chainstate/stacks/db/accounts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ impl FromRow<MinerPaymentSchedule> for MinerPaymentSchedule {
7979
let stacks_block_height = u64::from_column(row, "stacks_block_height")?;
8080
let vtxindex: u32 = row.get_unwrap("vtxindex");
8181

82-
let schedule_type: HeaderTypeNames = row
83-
.get("schedule_type")
84-
.unwrap_or_else(|_e| HeaderTypeNames::Epoch2);
82+
let schedule_type: HeaderTypeNames =
83+
row.get("schedule_type").unwrap_or(HeaderTypeNames::Epoch2);
8584

8685
let coinbase = coinbase_text
8786
.parse::<u128>()

stackslib/src/chainstate/stacks/db/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,8 @@ impl FromRow<StacksHeaderInfo> for StacksHeaderInfo {
442442
.parse::<u64>()
443443
.map_err(|_| db_error::ParseError)?;
444444

445-
let header_type: HeaderTypeNames = row
446-
.get("header_type")
447-
.unwrap_or_else(|_e| HeaderTypeNames::Epoch2);
445+
let header_type: HeaderTypeNames =
446+
row.get("header_type").unwrap_or(HeaderTypeNames::Epoch2);
448447
let stacks_header: StacksBlockHeaderTypes = {
449448
match header_type {
450449
HeaderTypeNames::Epoch2 => StacksBlockHeader::from_row(row)?.into(),

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,11 +2408,11 @@ impl StacksBlockBuilder {
24082408
.elapsed()
24092409
.as_millis()
24102410
.try_into()
2411-
.unwrap_or_else(|_| i64::MAX);
2411+
.unwrap_or(i64::MAX);
24122412
let time_estimate_ms: u64 = time_estimate_ms
24132413
.try_into()
24142414
// should be unreachable
2415-
.unwrap_or_else(|_| 0);
2415+
.unwrap_or(0);
24162416
update_timings.push((txinfo.tx.txid(), time_estimate_ms));
24172417
}
24182418

stackslib/src/cost_estimates/pessimistic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Samples {
143143
fn flush_sqlite(&self, tx: &SqliteTransaction, identifier: &str) {
144144
let sql = "INSERT OR REPLACE INTO pessimistic_estimator
145145
(estimate_key, current_value, samples) VALUES (?, ?, ?)";
146-
let current_value = u64_to_sql(self.mean()).unwrap_or_else(|_| i64::MAX);
146+
let current_value = u64_to_sql(self.mean()).unwrap_or(i64::MAX);
147147
tx.execute(sql, params![identifier, current_value, self.to_json()])
148148
.expect("SQLite failure");
149149
}

stackslib/src/monitoring/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub fn set_last_block_transaction_count(transactions_in_block: u64) {
132132
// Saturating cast from u64 to i64
133133
#[cfg(feature = "monitoring_prom")]
134134
prometheus::LAST_BLOCK_TRANSACTION_COUNT
135-
.set(i64::try_from(transactions_in_block).unwrap_or_else(|_| i64::MAX));
135+
.set(i64::try_from(transactions_in_block).unwrap_or(i64::MAX));
136136
}
137137

138138
/// Log `execution_cost` as a ratio of `block_limit`.
@@ -162,7 +162,7 @@ pub fn set_last_mined_block_transaction_count(transactions_in_block: u64) {
162162
// Saturating cast from u64 to i64
163163
#[cfg(feature = "monitoring_prom")]
164164
prometheus::LAST_MINED_BLOCK_TRANSACTION_COUNT
165-
.set(i64::try_from(transactions_in_block).unwrap_or_else(|_| i64::MAX));
165+
.set(i64::try_from(transactions_in_block).unwrap_or(i64::MAX));
166166
}
167167

168168
pub fn increment_btc_ops_sent_counter() {

0 commit comments

Comments
 (0)