Show Menu
Cheatography

Logic

Found
Stop testing when answer found
Frequency
Order tests by frequency in switch and if-else structures
Switch
Substitute switch statement for if-else construct
Lookup Table
Substitute table lookups for compli­cated expres­sions
Lazy Evaluation
Only a few entries are ever used. Cache them for further use it may be better to compute values as needed.
 

Loops

Unswit­ching
If the decision doesn’t change while looping turn the loop inside out
Jamming
Combines two or more loops into one. Reduces loop overhead
Unrolling
Replaces a loop with straig­ht-line code. With partial unrolling, two or more cases are handled inside
Minimize work
Put calcul­ations that result in a constant before the loop
Sentinel Values
Special value that marks the end of an array. Replaces expensive compound tests
Busy Loop Inside
Putting the busiest loop on the inside
 

General

Routines - Inline
Rewrite routines inline
Routine - Rewrite
Rewrite expensive system routines
Data tran – Float/Int
Replace f.p. numbers with integers
Data tran – Array Dims
Reduce array dimensions where possible
Data tran – Array Refs
Minimize array references
Data tran – Supp
Length index for arrays
Data tran – Caching
Save commonly used values, instead of recomp­uting or rereading them
Exp - Str redu
Replace expensive operations with cheaper ones
Exp - Compile Time
Initialize at compile time
Exp - Data Type
Use the proper data type for constants
Common Sub-Exp
Eliminate common subexp­res­sions
Exp - Precompute
Better to look up values than to recompute them
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by Heavenel