User:Void Singer/Optimizations
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
- 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
- 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" )){
- when incrementing counters or variables
- use (++vIntCount)
- instead of (vIntCount++) or (vIntCount += 1) or (vIntCount = vIntCount + 1)
- because it runs faster
- 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
- Other Useful Optimizations
Comments
Feel free to leave me a note on my User Talk page.