User:Void Singer/Optimizations

From Second Life Wiki
< User:Void Singer
Revision as of 02:36, 1 December 2007 by Void Singer (talk | contribs) (cleanup)
Jump to navigation Jump to search

Coding Practices: Optimizations

This is a list of current coding optimizations and "hacks" I use in LSL and in examples They are all tested personally

  1. when testing a function that returns -1 on NOT_FOUND
    • use (~test_function) -[eg. if (~llSubStringIndex( "abcdef", "t")){
    • instead of (test_function != -1) -[eg. if (llSubStringIndex( "abcdef", "t") != -1){
    • because it runs faster -[(!~test_function) also works for FOUND
  2. when testing a list for a specific single entry
    • use llListFindList( vLstBase, (list)"test" )
    • instead of llListFindList( vLstBase, ["test"] )
    • because it runs faster and smaller compiled -[eg. if (llListFindList( vLstBase, (list)"test" )){
  3. when incrementing counters or variables
    • use (++vIntCount)
    • instead of (vIntCount++) or (vIntCount += 1) or (vIntCount = vIntCount + 1)
    • because it runs faster
  4. When testing if/else conditions place true statement first if possible
    • use (test) or (test == value)
    • instead of (!test) or (test != value)
    • because it's clearer & faster
  5. Other Useful Optimizations

Comments

Feel free to leave me a note on my User Talk page.