[Webkit-unassigned] [Bug 34548] audio engine: add Vector3 class

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Feb 4 17:10:52 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=34548


Darin Adler <darin at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #48182|review?                     |review+
               Flag|                            |




--- Comment #13 from Darin Adler <darin at apple.com>  2010-02-04 17:10:51 PST ---
(From update of attachment 48182)
> +    void normalize()
> +    {
> +        if (isZero())
> +            return;
> +
> +        double k = 1.0 / abs();
> +        m_x *= k;
> +        m_y *= k;
> +        m_z *= k;
> +    }

Seems to me it would be more efficient to check the result of abs() for 0.0
rather than separately checking isZero. One equality check against zero instead
of three in the normal case.

> +inline Vector3 operator*(double k, const Vector3& v)
> +{
> +    return Vector3(k * v.x(), k * v.y(), k * v.z());
> +}

I think you should also include the version where the vector is on the left.

> +	Vector3 v = v1 - v2;
> +    return v.abs();

There's a stray tab in here on that first line, that needs to be fixed.

You can just write this without the named temporary as

    return (v1 - v2).abs();

Seems a little cleaner like that to me.

r=me but you can’t land until you get rid of that tab.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list