20,000 USDC
View results
Submission Details
Severity: gas
Valid

 <x> += <y> Costs More Gas Than <x> = <x> + <y> For State Variables

AVOID COMPOUND ASSIGNMENT OPERATOR IN STATE VARIABLES
Using compound assignment operators for state variables (like State += X or State -= X …) it’s more expensive than using operator assignment (like State = State + X or State = State - X …).

	pragma solidity 0.8.15;
	contract TesterA {
	uint256 private _a;
	function testShort() public {

⚔️ _a += 1;
}

	}
	contract TesterB {
	Uint256 private _a;
	function testLong() public {
	_a = _a + 1;
	}
	}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.