Appearance
TempTable
Inherits: LibTSMModule
Functions
Acquire
lua
function BaseType.TempTable.Acquire(...)
-> tableAcquires a temporary table. Temporary tables are recycled tables which can be used instead of creating a new table every time one is needed for a defined lifecycle. This avoids relying on the garbage collector and improves overall performance.
Parameters:
| Name | Type | Description |
|---|---|---|
... | any | Any number of values to insert into the table initially |
Returns:
| Type | Description |
|---|---|
table |
AcquireWithOwner
lua
function BaseType.TempTable.AcquireWithOwner(owner, ...)
-> tableAcquires a temporary table and takes ownership.
Parameters:
| Name | Type | Description |
|---|---|---|
owner | table | The owner |
... | any | Any number of values to insert into the table initially |
Returns:
| Type | Description |
|---|---|
table |
ConcatAndRelease
lua
function BaseType.TempTable.ConcatAndRelease(tbl, sep, startIndex, endIndex)
-> stringConcatenates the temporary table and releases it.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | string[] | The temporary table |
sep | string | The separator |
startIndex | number | The first index to concat |
endIndex | number | The last index to concat |
Returns:
| Type | Description |
|---|---|
string |
EnableLeakDebug
lua
function BaseType.TempTable.EnableLeakDebug()Enables tracking of where temp tables are created from in order to debug leaks.
GetDebugInfo
lua
function BaseType.TempTable.GetDebugInfo()
-> string[]Gets debug information describing allocated and free temp tables.
Returns:
| Type | Description |
|---|---|
string[] |
Iterator
lua
function BaseType.TempTable.Iterator(tbl, numFields)
-> fun():number, ...any, table, numberIterators over a temporary table, releasing it when done. NOTE: This iterator must be run to completion and not be interrupted (i.e. with a break or return).
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The temporary table to iterator over |
numFields | number | The number of fields to unpack with each iteration (defaults to 1) |
Returns:
| Type | Description |
|---|---|
fun():number, ...any | Iterator with fields: index, {numFields...} |
table | |
number |
KeyIterator
lua
function BaseType.TempTable.KeyIterator(tbl)
-> fun():number, ...any, tableIterators over the keys of a temporary table, releasing it when done. NOTE: This iterator must be run to completion and not be interrupted (i.e. with a break or return).
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The temporary table to iterator over |
Returns:
| Type | Description |
|---|---|
fun():number, ...any | Iterator with fields: key |
table |
Release
lua
function BaseType.TempTable.Release(tbl)Releases a temporary table. The temporary table will be returned to the pool and must not be accessed after being released.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The temporary table to release |
ReleaseAllOwned
lua
function BaseType.TempTable.ReleaseAllOwned(owner)Releases all owned temp tables.
Parameters:
| Name | Type | Description |
|---|---|---|
owner | table | The owner |
TakeOwnership
lua
function BaseType.TempTable.TakeOwnership(tbl, owner)Assigns ownership of a temp table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | table | The temp table |
owner | table | The owner |
UnpackAndRelease
lua
function BaseType.TempTable.UnpackAndRelease(tbl)
-> ...<T>Releases the temporary table and returns its unpacked values.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | T[] | The temporary table to release and unpack |
Returns:
| Type | Description |
|---|---|
...<T> |