ton-blockchain / wallet-contract-v5

w5
MIT License
69 stars 16 forks source link

Minor optimization suggestions #26

Closed akifoq closed 1 month ago

akifoq commented 1 month ago

I'm late to the deadline but it's also not in the scope of the contest, so there are just a few suggestions for the greater good:

  1. The throw_unless(error::invalid_c5, cs.slice_refs() == 0); (L88) is redundant and can be safely removed (the while loop condition already guarantees that the slice is empty, thus has zero refs).
  2. L99 can be replaced with ifnot (cs~load_int(1)) {.
  3. Lines 181-185 can be rephrased as
    throw_if(error::invalid_signature, is_external);
    return ();

These 3 simple optimizations (mainly the third one due to FunC compiler stop emitting CONT<{...}> EXECUTE pattern) allow to decrease gas usage for single external transfer from 5049 to 4647 gas units (by 8%).

tolya-yanot commented 1 month ago

Not in the context of the contest, but thanks.

3 - resourceful.