From a401ca8a175db27a032e228c8ced7cc924083210 Mon Sep 17 00:00:00 2001
From: Robert Konigsberg <konigsberg@google.com>
Date: Thu, 14 Jun 2012 14:16:18 -0400
Subject: [PATCH] Mild code reduction by eliminating duplication

---
 dygraph-canvas.js | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/dygraph-canvas.js b/dygraph-canvas.js
index aff9002..d588b9c 100644
--- a/dygraph-canvas.js
+++ b/dygraph-canvas.js
@@ -725,6 +725,16 @@ DygraphCanvasRenderer.prototype._drawStyledLine = function(
   ctx.restore();
 };
 
+DygraphCanvasRenderer.prototype._drawPointsOnLine = function(ctx, pointsOnLine, drawPointCallback, setName, color, pointSize) {
+  for (var idx = 0; idx < pointsOnLine.length; idx++) {
+    var cb = pointsOnLine[idx];
+    ctx.save();
+    drawPointCallback(
+        this.dygraph_, setName, ctx, cb[0], cb[1], color, pointSize);
+    ctx.restore();
+  }
+}
+
 DygraphCanvasRenderer.prototype._drawNonTrivialLine = function(
     ctx, points, setLength, firstIndexInSet, setName, color, strokeWidth, strokePattern, drawPointCallback, pointSize, drawPoints, drawGapPoints, stepPlot) {
   var prevX = null;
@@ -794,13 +804,7 @@ DygraphCanvasRenderer.prototype._drawNonTrivialLine = function(
       }
     }
   }
-  for (var idx = 0; idx < pointsOnLine.length; idx++) {
-    var cb = pointsOnLine[idx];
-    ctx.save();
-    drawPointCallback(
-        this.dygraph_, setName, ctx, cb[0], cb[1], color, pointSize);
-    ctx.restore();
-  }
+  this._drawPointsOnLine(ctx, pointsOnLine, drawPointCallback, setName, color, pointSize);
 };
 
 DygraphCanvasRenderer.prototype._drawTrivialLine = function(
@@ -844,13 +848,7 @@ DygraphCanvasRenderer.prototype._drawTrivialLine = function(
     }
   }
   ctx.stroke();
-  for (var idx = 0; idx < pointsOnLine.length; idx++) {
-    var cb = pointsOnLine[idx];
-    ctx.save();
-    drawPointCallback(
-        this.dygraph_, setName, ctx, cb[0], cb[1], color, pointSize);
-    ctx.restore();
-  }
+  this._drawPointsOnLine(ctx, pointsOnLine, drawPointCallback, setName, color, pointSize);
 };
 
 DygraphCanvasRenderer.prototype._drawLine = function(ctx, i) {
-- 
2.7.4