Skip to content

optimize price storage loop#2

Open
abiiralbhattarai wants to merge 1 commit into
wormhole-foundation:mainfrom
abiiralbhattarai:refactor/optimize-price-storage-loop
Open

optimize price storage loop#2
abiiralbhattarai wants to merge 1 commit into
wormhole-foundation:mainfrom
abiiralbhattarai:refactor/optimize-price-storage-loop

Conversation

@abiiralbhattarai

Copy link
Copy Markdown

Description

This PR optimizes the gas efficiency of the price storage loop in PriceFeedReceiver.sol. By leveraging unchecked blocks and prefix increments, we reduce the overhead of each iteration.

Changes

  • Implemented unchecked increments: Since the loop counter i is constrained by the array length, overflow is impossible. Using unchecked skips redundant safety checks.
  • Used Prefix Increment (++i): Unlike i++, which creates a temporary variable to return the old value, ++i increments the variable directly in place.

Impact

  • Gas Savings: Approximately ~50 gas per iteration.

@vercel

vercel Bot commented Jan 23, 2026

Copy link
Copy Markdown

@abiiralbhattarai is attempting to deploy a commit to the Wormhole Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant