From 99a77a04a9365f17176de36deaa4d9db01e4d362 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Fri, 1 Jun 2012 11:35:41 -0400 Subject: [PATCH] Add some tepid comments, use of local variables, etc. --- dygraph-canvas.js | 3 +++ dygraph-layout.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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] = { -- 2.7.4