Skip to content

Commit

Permalink
Remove inappropriate use of usize. Refactor upcast. (solana-labs#32539)
Browse files Browse the repository at this point in the history
* Remove inappropriate use of usize. Refactor upcast.
Co-authored-by: Trent Nelson <[email protected]>
  • Loading branch information
willhickey authored Jul 20, 2023
1 parent be10168 commit 83ac15d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions program-runtime/src/compute_budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl ComputeBudget {
enable_request_heap_frame_ix: bool,
support_set_loaded_accounts_data_size_limit_ix: bool,
) -> Result<PrioritizationFeeDetails, TransactionError> {
let mut num_non_compute_budget_instructions: usize = 0;
let mut num_non_compute_budget_instructions: u32 = 0;
let mut updated_compute_unit_limit = None;
let mut requested_heap_size = None;
let mut prioritization_fee = None;
Expand Down Expand Up @@ -261,18 +261,19 @@ impl ComputeBudget {
self.heap_size = Some(bytes as usize);
}

self.compute_unit_limit = if default_units_per_instruction {
let compute_unit_limit = if default_units_per_instruction {
updated_compute_unit_limit.or_else(|| {
Some(
(num_non_compute_budget_instructions as u32)
num_non_compute_budget_instructions
.saturating_mul(DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT),
)
})
} else {
updated_compute_unit_limit
}
.unwrap_or(MAX_COMPUTE_UNIT_LIMIT)
.min(MAX_COMPUTE_UNIT_LIMIT) as u64;
.min(MAX_COMPUTE_UNIT_LIMIT);
self.compute_unit_limit = u64::from(compute_unit_limit);

self.loaded_accounts_data_size_limit = updated_loaded_accounts_data_size_limit
.unwrap_or(MAX_LOADED_ACCOUNTS_DATA_SIZE_BYTES)
Expand Down

0 comments on commit 83ac15d

Please sign in to comment.