@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 +25 -29
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +25 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +25 -29
- package/dist/index.mjs.map +1 -1
- package/dist/lib/data-table/data-table.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -159,42 +159,38 @@ class DataTable {
|
|
|
159
159
|
* After calling, row `i` will contain the data that was previously at row `indices[i]`.
|
|
160
160
|
*
|
|
161
161
|
* This is a memory-efficient alternative to `permuteRows` that modifies the table
|
|
162
|
-
* in-place rather than creating a copy.
|
|
162
|
+
* in-place rather than creating a copy. It reuses ArrayBuffers between columns to
|
|
163
|
+
* minimize memory allocations.
|
|
163
164
|
*
|
|
164
165
|
* @param indices - Array of indices defining the permutation. Must have the same
|
|
165
166
|
* length as the number of rows, and must be a valid permutation
|
|
166
167
|
* (each index 0 to n-1 appears exactly once).
|
|
167
168
|
*/
|
|
168
169
|
permuteRowsInPlace(indices) {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// Save values at position i
|
|
177
|
-
for (let c = 0; c < numCols; c++) {
|
|
178
|
-
temps[c] = this.columns[c].data[i];
|
|
170
|
+
// Cache for reusing ArrayBuffers by size
|
|
171
|
+
const cache = new Map();
|
|
172
|
+
const getBuffer = (size) => {
|
|
173
|
+
const cached = cache.get(size);
|
|
174
|
+
if (cached) {
|
|
175
|
+
cache.delete(size);
|
|
176
|
+
return cached;
|
|
179
177
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
for (let c = 0; c < numCols; c++) {
|
|
194
|
-
this.columns[c].data[j] = this.columns[c].data[next];
|
|
195
|
-
}
|
|
196
|
-
j = next;
|
|
178
|
+
return new ArrayBuffer(size);
|
|
179
|
+
};
|
|
180
|
+
const returnBuffer = (buffer) => {
|
|
181
|
+
cache.set(buffer.byteLength, buffer);
|
|
182
|
+
};
|
|
183
|
+
const n = this.numRows;
|
|
184
|
+
for (const column of this.columns) {
|
|
185
|
+
const src = column.data;
|
|
186
|
+
const constructor = src.constructor;
|
|
187
|
+
const dst = new constructor(getBuffer(src.byteLength));
|
|
188
|
+
// Sequential writes are cache-friendly
|
|
189
|
+
for (let i = 0; i < n; i++) {
|
|
190
|
+
dst[i] = src[indices[i]];
|
|
197
191
|
}
|
|
192
|
+
returnBuffer(src.buffer);
|
|
193
|
+
column.data = dst;
|
|
198
194
|
}
|
|
199
195
|
}
|
|
200
196
|
}
|
|
@@ -3725,7 +3721,7 @@ class CompressedChunk {
|
|
|
3725
3721
|
}
|
|
3726
3722
|
}
|
|
3727
3723
|
|
|
3728
|
-
var version = "1.4.
|
|
3724
|
+
var version = "1.4.1";
|
|
3729
3725
|
|
|
3730
3726
|
const generatedByString = `Generated by splat-transform ${version}`;
|
|
3731
3727
|
const chunkProps = [
|