freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] Question about optimizing FT_MulFix.


From: Tom Kacvinsky
Subject: [Devel] Question about optimizing FT_MulFix.
Date: Sun, 29 Apr 2001 20:31:05 -0400 (EDT)

The current code for the 64 bit version of FT_MulFix is:

#ifdef FT_LONG64

  FT_EXPORT_DEF( FT_Long )  FT_MulFix( FT_Long  a,
                                       FT_Long  b )
  {
    FT_Int  s;


    s = 1;
    if ( a < 0 ) { a = -a; s = -s; }
    if ( b < 0 ) { b = -b; s = -s; }

    return s * (FT_Long)( ( (FT_Int64)a * b + 0x8000 ) >> 16 );
  }

#endif

I don't understand the use of adding 0x8000, and the sign changing.

I think this is just as accurate:

#ifdef FT_LONG64

  FT_EXPORT_DEF( FT_Long )  FT_MulFix( FT_Long  a,
                                       FT_Long  b )
  {

    return (FT_Long)( ( (FT_Int64)a * b ) >> 16 );
  }

#endif

Moreover, we avoid the two comparisons, the addition of 0x8000, and
the multiplication by s.  This has to be worth *some* optimization.

What say you?

Tom




reply via email to

[Prev in Thread] Current Thread [Next in Thread]