Breaking out of evaluateAnnotations early if there are no annotations.
authorAnthony Robledo <antrob@google.com>
Mon, 27 Jun 2011 18:49:09 +0000 (14:49 -0400)
committerAnthony Robledo <antrob@google.com>
Mon, 27 Jun 2011 18:49:09 +0000 (14:49 -0400)
This resulted in about an 8% speedup.

dygraph-layout.js

index 9c70965..99ae50c 100644 (file)
@@ -222,6 +222,13 @@ DygraphLayout.prototype._evaluateAnnotations = function() {
   }
 
   this.annotated_points = [];
+
+  // Exit the function early if there are no annotations.
+  if (!this.annotations || !this.annotations.length) {
+    return;
+  }
+  
+  // TODO(antrob): loop through annotations not points.
   for (var i = 0; i < this.points.length; i++) {
     var p = this.points[i];
     var k = p.xval + "," + p.name;