Skip to content

Commit d708132

Browse files
committed
merge 'push' calls together
1 parent d8297a0 commit d708132

File tree

2 files changed

+37
-55
lines changed

2 files changed

+37
-55
lines changed

src/traces/scattergl/convert.js

+36-53
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ function getSymbolSdf(symbol) {
385385
}
386386

387387
function convertLinePositions(gd, trace, positions) {
388-
var count = positions.length / 2;
388+
var len = positions.length;
389+
var count = len / 2;
389390
var linePositions;
390391
var i;
391392

@@ -394,99 +395,81 @@ function convertLinePositions(gd, trace, positions) {
394395
linePositions = [];
395396
for(i = 0; i < count - 1; i++) {
396397
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
397-
linePositions.push(NaN);
398-
linePositions.push(NaN);
399-
linePositions.push(NaN);
400-
linePositions.push(NaN);
398+
linePositions.push(NaN, NaN, NaN, NaN);
401399
} else {
402-
linePositions.push(positions[i * 2]);
403-
linePositions.push(positions[i * 2 + 1]);
400+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
404401
if(!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
405-
linePositions.push(positions[i * 2 + 2]);
406-
linePositions.push(positions[i * 2 + 1]);
402+
linePositions.push(positions[i * 2 + 2], positions[i * 2 + 1]);
407403
} else {
408-
linePositions.push(NaN);
409-
linePositions.push(NaN);
404+
linePositions.push(NaN, NaN);
410405
}
411406
}
412407
}
413-
linePositions.push(positions[positions.length - 2]);
414-
linePositions.push(positions[positions.length - 1]);
408+
linePositions.push(positions[len - 2], positions[len - 1]);
415409
} else if(trace.line.shape === 'hvh') {
416410
linePositions = [];
417411
for(i = 0; i < count - 1; i++) {
418412
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
419413
if(!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
420-
linePositions.push(positions[i * 2]);
421-
linePositions.push(positions[i * 2 + 1]);
414+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
422415
} else {
423-
linePositions.push(NaN);
424-
linePositions.push(NaN);
416+
linePositions.push(NaN, NaN);
425417
}
426-
linePositions.push(NaN);
427-
linePositions.push(NaN);
418+
linePositions.push(NaN, NaN);
428419
}
429420
else {
430421
var midPtX = (positions[i * 2] + positions[i * 2 + 2]) / 2;
431-
linePositions.push(positions[i * 2]);
432-
linePositions.push(positions[i * 2 + 1]);
433-
linePositions.push(midPtX);
434-
linePositions.push(positions[i * 2 + 1]);
435-
linePositions.push(midPtX);
436-
linePositions.push(positions[i * 2 + 3]);
422+
linePositions.push(
423+
positions[i * 2],
424+
positions[i * 2 + 1],
425+
midPtX,
426+
positions[i * 2 + 1],
427+
midPtX,
428+
positions[i * 2 + 3]
429+
);
437430
}
438431
}
439-
linePositions.push(positions[positions.length - 2]);
440-
linePositions.push(positions[positions.length - 1]);
432+
linePositions.push(positions[len - 2], positions[len - 1]);
441433
} else if(trace.line.shape === 'vhv') {
442434
linePositions = [];
443435
for(i = 0; i < count - 1; i++) {
444436
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
445437
if(!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
446-
linePositions.push(positions[i * 2]);
447-
linePositions.push(positions[i * 2 + 1]);
438+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
448439
} else {
449-
linePositions.push(NaN);
450-
linePositions.push(NaN);
440+
linePositions.push(NaN, NaN);
451441
}
452-
linePositions.push(NaN);
453-
linePositions.push(NaN);
442+
linePositions.push(NaN, NaN);
454443
}
455444
else {
456445
var midPtY = (positions[i * 2 + 1] + positions[i * 2 + 3]) / 2;
457-
linePositions.push(positions[i * 2]);
458-
linePositions.push(positions[i * 2 + 1]);
459-
linePositions.push(positions[i * 2]);
460-
linePositions.push(midPtY);
461-
linePositions.push(positions[i * 2 + 2]);
462-
linePositions.push(midPtY);
446+
linePositions.push(
447+
positions[i * 2],
448+
positions[i * 2 + 1],
449+
positions[i * 2],
450+
midPtY,
451+
positions[i * 2 + 2],
452+
midPtY
453+
);
463454
}
464455
}
465-
linePositions.push(positions[positions.length - 2]);
466-
linePositions.push(positions[positions.length - 1]);
456+
linePositions.push(positions[len - 2], positions[len - 1]);
467457
} else if(trace.line.shape === 'vh') {
468458
linePositions = [];
469459
for(i = 0; i < count - 1; i++) {
470460
if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
471-
linePositions.push(NaN);
472-
linePositions.push(NaN);
473-
linePositions.push(NaN);
474-
linePositions.push(NaN);
461+
linePositions.push(NaN, NaN, NaN, NaN);
475462
}
476463
else {
477-
linePositions.push(positions[i * 2]);
478-
linePositions.push(positions[i * 2 + 1]);
464+
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
479465
if(!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
480-
linePositions.push(positions[i * 2]);
481-
linePositions.push(positions[i * 2 + 3]);
466+
linePositions.push(positions[i * 2], positions[i * 2 + 3]);
482467
} else {
483-
linePositions.push(NaN);
484-
linePositions.push(NaN);
468+
linePositions.push(NaN, NaN);
485469
}
486470
}
487471
}
488-
linePositions.push(positions[positions.length - 2]);
489-
linePositions.push(positions[positions.length - 1]);
472+
linePositions.push(positions[len - 2], positions[len - 1]);
490473
} else {
491474
linePositions = positions;
492475
}

src/traces/scattergl/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,7 @@ function plot(gd, subplot, cdata) {
505505
for(i = Math.floor(nextPos.length / 2); i--;) {
506506
var xx = nextPos[i * 2], yy = nextPos[i * 2 + 1];
507507
if(isNaN(xx) || isNaN(yy)) continue;
508-
pos.push(xx);
509-
pos.push(yy);
508+
pos.push(xx, yy);
510509
}
511510
fillOptions.fill = nextTrace.fillcolor;
512511
}

0 commit comments

Comments
 (0)