TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

Drawing card can be more gas-efficient

Summary

The drawCard function queries availableCards[Player].length three times.
This costs gas as it is always read from storage.

Impact

It would be better to abstract this query to a variable so the length value is read from storage once but used throughtout the code

Tools Used

Manual review

Recommendations

+ uint256[] storage cards = availableCards[player];
+ uint256 length = cards.length;
require(
- availableCards[player].length > 0
+ length > 0,
Updates

Lead Judging Commences

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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