Newer versions of Solidity compilers support for gas optimizations along with bug fixes and security patches, so updating to the latest version will not only make our code safer but cheaper as well.
To catch most of the recent optimizations, make sure we’re using the higher versions of Solitiy compilers, at least 0.8.4: pragma solidity ^0.8.4;