From 729195615531816625e8041e8f00a6b7cc57571f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 5 Jan 2014 20:42:28 +0100 Subject: [PATCH] Prevent unnecessary beans from being created. --- src/basic/Point.js | 18 +++++++++++------- src/core/PaperScript.js | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index 9abf966a..0b956d73 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -449,10 +449,12 @@ var Point = Base.extend(/** @lends Point# */{ * remain squared, or its square root should be calculated. * @return {Number} */ - getDistance: function(/* point, squared */) { - var point = Point.read(arguments), - squared = Base.read(arguments), - x = point.x - this.x, + getDistance: function(point, squared) { + // NOTE: Although we're reading from the argument list, we need the + // above arguments to prevent a bean from being created. + point = Point.read(arguments); + squared = Base.read(arguments); + var x = point.x - this.x, y = point.y - this.y, d = x * x + y * y; return squared ? d : Math.sqrt(d); @@ -636,9 +638,11 @@ var Point = Base.extend(/** @lends Point# */{ * @param {Point} point * @return {Number} the angle between the two vectors */ - getDirectedAngle: function(/* point */) { - var point = Point.read(arguments); - return Math.atan2(this.cross(point), this.dot(point)) * 180 / Math.PI; + getDirectedAngle: function(point) { + // NOTE: Although we're reading from the argument list, we need the + // above argument to prevent a bean from being created. + point = Point.read(arguments); + return Math.atan2(this.cross(_point), this.dot(_point)) * 180 / Math.PI; }, /** diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index 45ee7c34..02a41ccd 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -207,7 +207,7 @@ var PaperScript = Base.exports.PaperScript = (function() { replaceCode(node, arg + ' = _$_(' + arg + ', "' + node.operator[0] + '", 1)'); } - } else { + } else { // AssignmentExpression if (/^.=$/.test(node.operator) && node.left.type !== 'Literal') { var left = getCode(node.left),