From 1a6c5c8c6f520dc81ec7da136b7f5c0a4afcbc33 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sat, 26 Feb 2011 14:34:01 +0100 Subject: [PATCH] Doc: Change comment about using canvas.width = canvas.width instead of context.clearRect. --- src/document/Doc.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/document/Doc.js b/src/document/Doc.js index 83c37d33..c62667a0 100644 --- a/src/document/Doc.js +++ b/src/document/Doc.js @@ -29,9 +29,10 @@ Doc = Base.extend({ redraw: function() { if (this.canvas) { - // TODO: clearing the canvas by setting - // this.canvas.width = this.canvas.width might be faster.. - this.ctx.clearRect(0, 0, this.size.width + 1, this.size.height); + // Initial tests conclude that clearing the canvas is always + // faster than using clearRect: + // http://jsperf.com/clearrect-vs-setting-width/7 + this.ctx.clearRect(0, 0, this.size.width + 1, this.size.height + 1); for (var i = 0, l = this.layers.length; i < l; i++) { this.layers[i].draw(this.ctx, {}); }