Skip to content

Commit fedbfea

Browse files
committed
Optimization in webgl.process
Dropping a condition in two loops because it can be done beforehand.
1 parent 609797b commit fedbfea

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/renderers/sigma.renderers.webgl.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,14 @@
178178
// Push edges:
179179
for (k in this.edgeFloatArrays) {
180180
renderer = sigma.webgl.edges[k];
181+
a = this.edgeFloatArrays[k].edges;
181182

182-
for (a = this.edgeFloatArrays[k].edges, i = 0, l = a.length; i < l; i++) {
183-
if (!this.edgeFloatArrays[k].array)
184-
this.edgeFloatArrays[k].array = new Float32Array(
185-
a.length * renderer.POINTS * renderer.ATTRIBUTES
186-
);
183+
// Creating the necessary arrays
184+
this.edgeFloatArrays[k].array = new Float32Array(
185+
a.length * renderer.POINTS * renderer.ATTRIBUTES
186+
);
187187

188+
for (i = 0, l = a.length; i < l; i++) {
188189

189190
// Just check that the edge and both its extremities are visible:
190191
if (
@@ -212,8 +213,14 @@
212213
// Push nodes:
213214
for (k in this.nodeFloatArrays) {
214215
renderer = sigma.webgl.nodes[k];
216+
a = this.nodeFloatArrays[k].nodes;
217+
218+
// Creating the necessary arrays
219+
this.nodeFloatArrays[k].array = new Float32Array(
220+
a.length * renderer.POINTS * renderer.ATTRIBUTES
221+
);
215222

216-
for (a = this.nodeFloatArrays[k].nodes, i = 0, l = a.length; i < l; i++) {
223+
for (i = 0, l = a.length; i < l; i++) {
217224
if (!this.nodeFloatArrays[k].array)
218225
this.nodeFloatArrays[k].array = new Float32Array(
219226
a.length * renderer.POINTS * renderer.ATTRIBUTES

0 commit comments

Comments
 (0)