From d25ca35b374190401bb2f251faaaa3c650e9a7f2 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Thu, 19 May 2011 23:56:29 +0200 Subject: [PATCH] Optimize comparison, by precalculating string comparison. --- src/color/Color.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/color/Color.js b/src/color/Color.js index e9dcecfb..88747586 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -219,12 +219,13 @@ var Color = this.Color = Base.extend(new function() { src._components = comps.concat(['alpha']); Base.each(comps, function(name) { var part = Base.capitalize(name), - name = '_' + name; + name = '_' + name, + isHue = name === '_hue'; this['get' + part] = function() { return this[name]; }; this['set' + part] = function(value) { - this[name] = name === '_hue' + this[name] = isHue // Keep negative values within modulo 360 too: ? ((value % 360) + 360) % 360 // All other values are 0..1