- this.setPointsLengths = new Array();
-
- for (var setName in this.datasets) {
- if (!this.datasets.hasOwnProperty(setName)) continue;
+ this.setPointsLengths = [];
+ this.setPointsOffsets = [];
+
+ var connectSeparated = this.attr_('connectSeparatedPoints');
+ // TODO(bhs): these loops are a hot-spot for high-point-count charts. In fact,
+ // on chrome+linux, they are 6 times more expensive than iterating through the
+ // points and drawing the lines. The brunt of the cost comes from allocating
+ // the |point| structures.
+ var i = 0;
+ var setIdx;
+
+ // Preallocating the size of points reduces reallocations, and therefore,
+ // calls to collect garbage.
+ var totalPoints = 0;
+ for (setIdx = 0; setIdx < this.datasets.length; ++setIdx) {
+ totalPoints += this.datasets[setIdx].length;
+ }
+ this.points = new Array(totalPoints);