Not faster. Smaller. I’m sure there’s no much difference speed-wise.
Once we add type safety to default values, it’ll be a bigger difference in terms of code size. On Aug 7, 2016, at 5:47 PM, Alex Harui <aha...@adobe.com> wrote: > > > On 8/7/16, 2:19 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >> BTW, I think another change to Language is a good idea: >> >> Currently default function parameters are compiled like this: >> >> public static function getBottomValue(value:Object, values:Object, >> reference:Number = NaN):Number >> { >> return getSideValue(value, values, 2, reference); >> } >> >> org.apache.flex.utils.CSSUtils.getBottomValue = function(value, values, >> reference) { >> reference = typeof reference !== 'undefined' ? reference : NaN; >> return org.apache.flex.utils.CSSUtils.getSideValue(value, values, 2, >> reference); >> }; >> >> This line cannot be completely optimized by the Closure compiler: >> reference = typeof reference !== 'undefined' ? reference : NaN; >> >> Here’s the best it does: >> c='undefined'!==typeof c?c:NaN; >> >> By doing this: >> Language.initialize(reference,”Number",NaN); >> I think it can be optimized to something like: >> cZ(c,fG,NaN); > > Why would a function call be faster than inline ternary expression? > > You can build a manual test with GCC to prove your hypothesis before we go > changing the compiler. IIRC, the pattern we use is a common one. > > Thanks, > -Alex