Skip to content

Instantly share code, notes, and snippets.

@IllIllI000
Last active June 24, 2023 13:48
Show Gist options
  • Save IllIllI000/1b70014db712f8572a72378321250058 to your computer and use it in GitHub Desktop.
Save IllIllI000/1b70014db712f8572a72378321250058 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
/**
* @title BoolStateVars
* @author IllIllI
*/
contract MappingBools {
mapping(uint => bool) data;
bool data2;
// optimize 200
// 43837 gas
function set_a81(uint idx, bool value) external {
data[idx] = value;
}
// optimize 200
// 43621 gas
function set2(bool value) external {
data2 = value;
}
}
contract MappingUint8s {
mapping(uint => uint8) data;
uint8 data2;
// optimize 200
// 43840 gas
function set_Hl1r(uint idx, uint8 value) external {
data[idx] = value;
}
// optimize 200
// 43627 gas
function set2(uint8 value) external {
data2 = value;
}
}
contract MappingUint256s {
mapping(uint => uint) data;
uint data2;
// optimize 200
// *43729 gas*
function set_2E3(uint idx, uint value) external {
data[idx] = value;
}
// optimize 200
// *43516* gas
function set2(uint value) external {
data2 = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment