Skip to content

Commit f7ab3c2

Browse files
committed
refactor(WebGL): remove support for WebGL1
1 parent 3aff1e3 commit f7ab3c2

29 files changed

Lines changed: 848 additions & 1386 deletions

File tree

Sources/Common/Core/CellArray/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,16 @@ function vtkCellArray(publicAPI, model) {
106106
cellPointIds = cell;
107107
}
108108
const cellId = publicAPI.getNumberOfCells();
109-
publicAPI.insertNextTuples([cellPointIds.length, ...cellPointIds]);
109+
// Build the [count, ...pointIds] record without the spread operator, which
110+
// would walk the iterator protocol and allocate an extra intermediate for
111+
// every inserted cell.
112+
const numberOfPoints = cellPointIds.length;
113+
const cellRecord = new Array(numberOfPoints + 1);
114+
cellRecord[0] = numberOfPoints;
115+
for (let i = 0; i < numberOfPoints; ++i) {
116+
cellRecord[i + 1] = cellPointIds[i];
117+
}
118+
publicAPI.insertNextTuples(cellRecord);
110119
// By computing the number of cells earlier, we made sure that numberOfCells is defined
111120
++model.numberOfCells;
112121
if (model.cellSizes != null) {

Sources/Common/DataModel/CellLinks/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ function vtkCellLinks(publicAPI, model) {
105105
* will be built.
106106
*/
107107
publicAPI.allocate = (numLinks, ext = 1000) => {
108-
model.array = Array(numLinks)
109-
.fill()
110-
.map(() => ({
111-
ncells: 0,
112-
cells: null,
113-
}));
108+
// Populate in a single pass. Array(n).fill().map() walks the array three
109+
// times (allocate sparse, fill, map) before producing the link objects.
110+
const array = new Array(numLinks);
111+
for (let i = 0; i < numLinks; ++i) {
112+
array[i] = { ncells: 0, cells: null };
113+
}
114+
model.array = array;
114115
model.extend = ext;
115116
model.maxId = -1;
116117
};

0 commit comments

Comments
 (0)