Consider adding a break in the loop once the validity of the provider is proved inside _isValidProvider
function _isValidProvider(address provider) internal view returns (bool check) {
uint256 len = _providers.length;
for (uint256 i = 0; i < len;) {
if (provider == address(_providers[i])) {
check = true;
<<break here>>
}
unchecked {
++i;
}
}
}
Once the match is found inside the providers array, you can break the loop and return. Doing so would save significant gas costs since no further SLOAD operations would be performed for the remaining providers.
Description
Consider adding a break in the loop once the validity of the provider is proved inside _isValidProvider
Once the match is found inside the providers array, you can break the loop and return. Doing so would save significant gas costs since no further SLOAD operations would be performed for the remaining providers.