From 0e26ab7d98f56c64f7043ae71821cd4ef69bc1c2 Mon Sep 17 00:00:00 2001 From: Shebin John Date: Fri, 10 Jan 2025 12:35:28 +0100 Subject: [PATCH] Comment explaining shift usage added --- contracts/common/StorageAccessible.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/common/StorageAccessible.sol b/contracts/common/StorageAccessible.sol index bd3530e1b..34aa6c612 100644 --- a/contracts/common/StorageAccessible.sol +++ b/contracts/common/StorageAccessible.sol @@ -15,6 +15,7 @@ abstract contract StorageAccessible { * @return the bytes that were read. */ function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) { + // We use `<< 5` instead of `* 32` as SHR / SHL opcode only uses 3 gas, while DIV / MUL opcode uses 5 gas. bytes memory result = new bytes(length << 5); for (uint256 index = 0; index < length; index++) { /* solhint-disable no-inline-assembly */