On Tue, Jun 3, 2014 at 3:48 PM, Till Schneidereit <t...@tillschneidereit.net
> wrote:

> On Wed, Jun 4, 2014 at 12:26 AM, Rik Cabanier <caban...@gmail.com> wrote:
>
>> > Actually, inverse() is already spec'd to throw if the inversion fails.
>> In
>> > that case (assuming we keep it that way) there is no need at all for any
>> > isInvertible kind of method. Note that in floating-point arithmetic
>> there
>> > is no absolute notion of invertibility; there just are different matrix
>> > inversion algorithms each failing on different matrices, so
>> "invertibility"
>> > only makes sense with respect to one inversion algorithm, so it is
>> actually
>> > better to keep the current exception-throwing API than to introduce a
>> > separate isInvertible getter.
>> >
>>
>> That would require try/catch around all the "invert()" calls. This is ugly
>> but more importantly, it will significantly slow down javascript
>> execution.
>> I'd prefer that we don't throw at all but we have to because SVGMatrix
>> did.
>>
>
> That isn't really true in modern engines. Just having a try/catch doesn't
> meaningfully slow down code anymore. If an exception is actually thrown, a
> (very) slow path is taken, but otherwise things are good.
>
> (I can only say this with certainty about SpiderMonkey and V8, but would
> assume that other engines behave similarly. And even if not, it doesn't
> make sense to make decisions like this based on their current performance
> characteristics.)
>

Interesting!
I wrote a small experiment: http://jsfiddle.net/G83mW/14/
Gecko is indeed impervious but Chrome, Safari and IE are not. V8 is between
4 and 6 times slower if there's a try/catch.

I agree that we shouldn't make decision on the current state. (FWIW I think
that exceptions should only be used for "exceptional" cases.)
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to