@playcanvas/splat-transform 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -11029,42 +11029,38 @@ class DataTable {
11029
11029
  * After calling, row `i` will contain the data that was previously at row `indices[i]`.
11030
11030
  *
11031
11031
  * This is a memory-efficient alternative to `permuteRows` that modifies the table
11032
- * in-place rather than creating a copy.
11032
+ * in-place rather than creating a copy. It reuses ArrayBuffers between columns to
11033
+ * minimize memory allocations.
11033
11034
  *
11034
11035
  * @param indices - Array of indices defining the permutation. Must have the same
11035
11036
  * length as the number of rows, and must be a valid permutation
11036
11037
  * (each index 0 to n-1 appears exactly once).
11037
11038
  */
11038
11039
  permuteRowsInPlace(indices) {
11039
- const n = this.numRows;
11040
- const numCols = this.columns.length;
11041
- const visited = new Uint8Array(n);
11042
- const temps = new Array(numCols);
11043
- for (let i = 0; i < n; i++) {
11044
- if (visited[i] || indices[i] === i)
11045
- continue;
11046
- // Save values at position i
11047
- for (let c = 0; c < numCols; c++) {
11048
- temps[c] = this.columns[c].data[i];
11040
+ // Cache for reusing ArrayBuffers by size
11041
+ const cache = new Map();
11042
+ const getBuffer = (size) => {
11043
+ const cached = cache.get(size);
11044
+ if (cached) {
11045
+ cache.delete(size);
11046
+ return cached;
11049
11047
  }
11050
- // Walk the cycle
11051
- let j = i;
11052
- while (true) {
11053
- const next = indices[j];
11054
- visited[j] = 1;
11055
- if (next === i) {
11056
- // End of cycle - place saved values
11057
- for (let c = 0; c < numCols; c++) {
11058
- this.columns[c].data[j] = temps[c];
11059
- }
11060
- break;
11061
- }
11062
- // Move values from next to j
11063
- for (let c = 0; c < numCols; c++) {
11064
- this.columns[c].data[j] = this.columns[c].data[next];
11065
- }
11066
- j = next;
11048
+ return new ArrayBuffer(size);
11049
+ };
11050
+ const returnBuffer = (buffer) => {
11051
+ cache.set(buffer.byteLength, buffer);
11052
+ };
11053
+ const n = this.numRows;
11054
+ for (const column of this.columns) {
11055
+ const src = column.data;
11056
+ const constructor = src.constructor;
11057
+ const dst = new constructor(getBuffer(src.byteLength));
11058
+ // Sequential writes are cache-friendly
11059
+ for (let i = 0; i < n; i++) {
11060
+ dst[i] = src[indices[i]];
11067
11061
  }
11062
+ returnBuffer(src.buffer);
11063
+ column.data = dst;
11068
11064
  }
11069
11065
  }
11070
11066
  }
@@ -14299,7 +14295,7 @@ class CompressedChunk {
14299
14295
  }
14300
14296
  }
14301
14297
 
14302
- var version = "1.4.0";
14298
+ var version = "1.4.1";
14303
14299
 
14304
14300
  const generatedByString = `Generated by splat-transform ${version}`;
14305
14301
  const chunkProps = [