Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
new hashmap with capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Jun 18, 2021
1 parent 1025d2f commit 6965929
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion core/src/cost_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use crate::cost_model::TransactionCost;
use solana_sdk::{clock::Slot, pubkey::Pubkey};
use std::collections::HashMap;

const WRITABLE_ACCOUNTS_PER_BLOCK: usize = 512;

#[derive(Debug, Clone)]
pub struct CostTracker {
account_cost_limit: u64,
Expand All @@ -21,7 +23,7 @@ impl CostTracker {
account_cost_limit: chain_max,
block_cost_limit: package_max,
current_bank_slot: 0,
cost_by_writable_accounts: HashMap::new(),
cost_by_writable_accounts: HashMap::with_capacity(WRITABLE_ACCOUNTS_PER_BLOCK),
block_cost: 0,
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/execute_cost_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ impl ExecuteCostTable {
pub fn new(cap: usize) -> Self {
Self {
capacity: cap,
table: HashMap::new(),
occurrences: HashMap::new(),
table: HashMap::with_capacity(cap),
occurrences: HashMap::with_capacity(cap),
}
}

Expand Down

0 comments on commit 6965929

Please sign in to comment.