class Int32BufferCache
package foxlite.system
A collection of Int32Array that's meant to be used as a typed array storage from an existing data.
Static variables
Static methods
staticget(data:Array<Int>):Int32Array
Gets a buffer of specified length by data.length and fills it with data. Else one is created and added to the cache.
Use this to prevent wasteful allocations when creating multiple typed arrays of the same length that have the sole purpose of holding data.
For example, this function is used in FoxShader to write uniform arrays, and gets called a lot:
var buffer = Int32BufferCache.get(data);
gl.uniform1iv(location, buffer);
After that, we no longer need the buffer, so we can call get() again for the next uniform rather than letting it be garbage collected.