Local API and tables – ShiVa Engine

Local API and tables

Assigning member variables, tables and even functions to local variables before working with them in loops will reduce processing time significantly, can be used with most if not all shiva API functions.

    local iStep == this.nStep ( )
    local L_tTable = this.tTable ( )
    local L_fTable_Add = table.add
    for i = 0, 100
    do
      if (iStep == i) then
      L_fTable_Add ( L_tTable, iStep )
      end
    end

Milliseconds slower, therefor a bad idea:

    for i = 0, 100
    do
      if (this.nStep ( ) == i) then
      table.add ( this.tTable ( ), this.nStep ( ))
      end
    end



Need more answers?

  • slackBanner