From: Robert Konigsberg Date: Fri, 1 Jun 2012 15:35:41 +0000 (-0400) Subject: Add some tepid comments, use of local variables, etc. X-Git-Tag: v1.0.0~266^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=99a77a04a9365f17176de36deaa4d9db01e4d362;p=dygraphs.git Add some tepid comments, use of local variables, etc. --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index d3e0d4f..de8d4fe 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -698,6 +698,7 @@ DygraphCanvasRenderer.isNullOrNaN_ = function(x) { DygraphCanvasRenderer.prototype._drawStyledLine = function( ctx, i, setName, color, strokeWidth, strokePattern, drawPoints, drawPointCallback, pointSize) { + // TODO(konigsberg): Compute attributes outside this method call. var stepPlot = this.attr_("stepPlot"); var firstIndexInSet = this.layout.setPointsOffsets[i]; var setLength = this.layout.setPointsLengths[i]; @@ -850,6 +851,8 @@ DygraphCanvasRenderer.prototype._drawLine = function(ctx, i) { var borderWidth = this.dygraph_.attr_("strokeBorderWidth", setName); var drawPointCallback = this.dygraph_.attr_("drawPointCallback", setName) || Dygraph.Circles.DEFAULT; + + // TODO(konigsberg): Turn this into one call, and then consider inlining drawStyledLine. if (borderWidth && strokeWidth) { this._drawStyledLine(ctx, i, setName, this.dygraph_.attr_("strokeBorderColor", setName), diff --git a/dygraph-layout.js b/dygraph-layout.js index e55f62b..1fe4228 100644 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@ -219,6 +219,9 @@ DygraphLayout.prototype._evaluateLineCharts = function() { // points and drawing the lines. The brunt of the cost comes from allocating // the |point| structures. var i = 0; + + // Preallocating the size of points reduces reallocations, and therefore, + // calls to collect garbage. var totalPoints = 0; for (var setIdx = 0; setIdx < this.datasets.length; ++setIdx) { totalPoints += this.datasets[setIdx].length; @@ -241,7 +244,7 @@ DygraphLayout.prototype._evaluateLineCharts = function() { // Range from 0-1 where 0 represents top and 1 represents bottom var yNormal = DygraphLayout._calcYNormal(axis, yValue); - if (connectSeparated && item[1] === null) { + if (connectSeparated && yValue === null) { yValue = null; } this.points[i] = {