The setCountry() function iterates over the input array countries. Reading the length of an array is an SSTORE operation in memory, and doing this on every iteration (countries.length) adds unnecessary overhead.
The gas cost can be reduced by caching the length of the array in a local variable before the loop starts.
Likelihood:
Reason 1: The gas cost is incurred every time the function is called because it reads from state.
Impact:
Minor (Gas)
Gas Overspending: Leads to higher transaction costs for the owner when setting up the tournament, especially given the large array size (48 elements).
Cache the array length outside the loop using a local variable.
Gas optimizations are invalid according to the CodeHawks documentation.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.