[prev] [index] [next]

Efficiency Tricks (cont)

Caching
  • remember earlier results instead of recomputing
  • store computed value with the data used to compute it
Buffering
  • perform input/output in chunks to minimise disk traffic
Separate out special cases
  • can help to make loops uniform, thus reducing tests
Use data instead of code
  • implement a function via a lookup table, rather than computing