Skip to content

Commit 46a6b6c

Browse files
committed
minor speedup - avoid some boolean checks in the scattergl conversion loop
1 parent 5b71b47 commit 46a6b6c

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/plots/cartesian/axis_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var orderedCategories = require('./ordered_categories');
2626
var axisIds = require('./axis_ids');
2727
var autoType = require('./axis_autotype');
2828

29+
2930
/**
3031
* options: object containing:
3132
*

src/traces/scattergl/convert.js

+17-14
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,28 @@ proto.updateFast = function(options) {
303303

304304
// TODO add 'very fast' mode that bypasses this loop
305305
// TODO bypass this on modebar +/- zoom
306-
for(var i = 0; i < len; ++i) {
307-
xx = x[i];
308-
yy = y[i];
306+
if(fastType || isDateTime) {
309307

310-
if(isNumeric(yy) && (fastType || isDateTime)) {
308+
for(var i = 0; i < len; ++i) {
309+
xx = x[i];
310+
yy = y[i];
311311

312-
if(!fastType) {
313-
xx = Lib.dateTime2ms(xx);
314-
}
312+
if(isNumeric(yy)) {
313+
314+
if(!fastType) {
315+
xx = Lib.dateTime2ms(xx);
316+
}
315317

316-
idToIndex[pId++] = i;
318+
idToIndex[pId++] = i;
317319

318-
positions[ptr++] = xx;
319-
positions[ptr++] = yy;
320+
positions[ptr++] = xx;
321+
positions[ptr++] = yy;
320322

321-
bounds[0] = Math.min(bounds[0], xx);
322-
bounds[1] = Math.min(bounds[1], yy);
323-
bounds[2] = Math.max(bounds[2], xx);
324-
bounds[3] = Math.max(bounds[3], yy);
323+
bounds[0] = Math.min(bounds[0], xx);
324+
bounds[1] = Math.min(bounds[1], yy);
325+
bounds[2] = Math.max(bounds[2], xx);
326+
bounds[3] = Math.max(bounds[3], yy);
327+
}
325328
}
326329
}
327330

0 commit comments

Comments
 (0)