From aae88d7568313b7e2cf4d6ff97d5312b3454e282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 14 Mar 2011 22:13:01 +0100 Subject: [PATCH] Optimise chained return statements. --- src/color/Color.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/color/Color.js b/src/color/Color.js index 38947ea1..96400f7d 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -66,15 +66,15 @@ var Color = this.Color = Base.extend(new function() { if (!this._colorType) { // Called on the abstract Color class. Guess color type // from arg - if (arg.red !== undefined) { - return new RGBColor(arg.red, arg.green, arg.blue, - arg.alpha); - } else if (arg.gray !== undefined) { - return new GrayColor(arg.gray, arg.alpha); - } else if (arg.hue !== undefined) { - return new HSBColor(arg.hue, arg.saturation, - arg.brightness, arg.alpha); - } + return arg.red !== undefined + ? new RGBColor(arg.red, arg.green, arg.blue, arg.alpha) + : arg.gray !== undefined + ? new GrayColor(arg.gray, arg.alpha) + : arg.hue !== undefined + ? new HSBColor(arg.hue, arg.saturation, arg.brightness, + arg.alpha) + : new RGBColor(); // Fallback + } else { // Called on a subclass instance. Return the converted // color.