Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions crates/database/src/states/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ impl<DB: Database> State<DB> {
addresses: impl IntoIterator<Item = Address>,
) -> Result<Vec<u128>, DB::Error> {
// Make transition and update cache state
let mut transitions = Vec::new();
let mut balances = Vec::new();
for address in addresses {
let addresses_iter = addresses.into_iter();
let (lower, _) = addresses_iter.size_hint();
let mut transitions = Vec::with_capacity(lower);
let mut balances = Vec::with_capacity(lower);
for address in addresses_iter {
let original_account = self.load_cache_account(address)?;
let (balance, transition) = original_account.drain_balance();
balances.push(balance);
Expand Down
10 changes: 6 additions & 4 deletions crates/precompile/src/bls12_381/blst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,9 @@ pub(crate) fn map_fp2_to_g2_bytes(
pub(crate) fn p1_msm_bytes(
point_scalar_pairs: impl Iterator<Item = Result<G1PointScalar, crate::PrecompileError>>,
) -> Result<[u8; G1_LENGTH], crate::PrecompileError> {
let mut g1_points = Vec::new();
let mut scalars = Vec::new();
let (lower, _) = point_scalar_pairs.size_hint();
let mut g1_points = Vec::with_capacity(lower);
let mut scalars = Vec::with_capacity(lower);

// Parse all points and scalars
for pair_result in point_scalar_pairs {
Expand Down Expand Up @@ -718,8 +719,9 @@ pub(crate) fn p1_msm_bytes(
pub(crate) fn p2_msm_bytes(
point_scalar_pairs: impl Iterator<Item = Result<G2PointScalar, crate::PrecompileError>>,
) -> Result<[u8; G2_LENGTH], crate::PrecompileError> {
let mut g2_points = Vec::new();
let mut scalars = Vec::new();
let (lower, _) = point_scalar_pairs.size_hint();
let mut g2_points = Vec::with_capacity(lower);
let mut scalars = Vec::with_capacity(lower);

// Parse all points and scalars
for pair_result in point_scalar_pairs {
Expand Down
Loading