API Docs for:
Show:

DataOptimizer Class

Module: gs

The data optimizer is to optimize data structures coming from data files to make processing faster. One way of optimization for example is to convert regular array to typed arrays.

Methods

arrayToNativeArray

(
  • array
)
Int16Array static

Converts the specified number-array to a typed Int16 array.

Parameters:

  • array Array
    • The array to convert.

Returns:

Int16Array:

The typed array.

nativeArray16

(
  • size
)
Int16Array static

Creates a typed Int16 array if supported. Otherwise a regular array is created.

Parameters:

  • size Number
    • The size of the array in elements.(Not in bytes).

Returns:

Int16Array:

The Int16 array.

nativeArray16

(
  • size
)
Int8Array static

Creates a typed Int8 array if supported. Otherwise a regular array is created.

Parameters:

  • size Number
    • The size of the array in elements.(Not in bytes).

Returns:

Int8Array:

The Int8 array.

optimizeCommand

(
  • commands
  • index
  • command
)
private static

Optimizes a single command.

Parameters:

  • commands Object
    • A list of commands.
  • index Number
    • Index of the command in command-list.
  • command Object
    • The command to optimize.

optimizeCommonEventCall

(
  • commands
  • index
  • command
)
private static

Checks if a common event call can be optimized by inline it. In special cases, such as recursion or parameters, an optimization is no possible.

Parameters:

  • commands Object
    • A list of commands.
  • index Number
    • Index of the command in command-list.
  • command Object
    • The command to optimize.

Returns:

If true the call can be safly inline. Otherwise false

optimizeCommonEventCall

(
  • commands
  • index
  • command
)
private static

Optimizes a common event call.

Parameters:

  • commands Object
    • A list of commands.
  • index Number
    • Index of the command in command-list.
  • command Object
    • The command to optimize.

optimizeEventCommands

(
  • commands
)
static

Optimizes a list of event/scene commands by removing unnecessary commands like comments or empty commands. It also optimizes label jumps. Adds an optimized to the specified command-list to indicate that the list was already optimized. If optimized property of command-list is set to true this method will return immediately.

Parameters:

  • commands Object
    • A list of commands to optimize.

optimizeVariableAccess

(
  • data
)
static

Optimizes the variable-access by replacing the domain-string with the domain-index value at runtime to allow faster domain access using integer numbers instead of strings.

Parameters:

  • data Object
    • The data to opimize, e.g. the params-object of a command.

removeEmptyCommand

(
  • commands
  • command
)
private static

Removes a single empty command like a comment.

Parameters:

  • commands Object
    • A list of commands.
  • command Object
    • The command to optimize.