51100 sc insight gas inefficiency in prize removal logic
Previous51836 sc low contract cannot be paused despite inheriting pausableNext50493 sc low immutable proxy implementation mapping in restrictionsfactory breaks upgrade logic
Was this helpful?
Was this helpful?
function removePrize(
uint256 prizeId
) external onlyRole(ADMIN_ROLE) prizeIsActive(prizeId) {
prizes[prizeId].isActive = false;
uint256 len = prizeIds.length;
if (prizeId == prizeIds[len - 1]) {
prizeIds.pop();
} else {
for (uint256 i = 0; i < len; i++) {
if (prizeIds[i] == prizeId) {
prizeIds[i] = prizeIds[len - 1];
prizeIds.pop();
break;
}
}
}
emit PrizeRemoved(prizeId);
}