Avoid modulo operators against a power-of-two denominator.

* src/afcjk.c (af_hint_normal_stem), src/base/ftoutln.c
(ft_contour_has), src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_vvcurveto, cff_op_hhcurveto, cff_op_hvcurveto>,
src/gxvalid/gxvcommn.c (GXV_32BIT_ALIGNMENT_VALIDATE),
src/gxvalid/gxvfeat.c (gxv_feat_setting_validate): Replace `%' with
`&' operator.
This commit is contained in:
Alexei Podtelezhnikov 2012-02-29 13:45:24 +01:00 committed by Werner Lemberg
parent 5621fdd412
commit b25265c5e4
6 changed files with 27 additions and 21 deletions

View File

@ -1,3 +1,14 @@
2012-02-29 Alexei Podtelezhnikov <apodtele@gmail.com>
Avoid modulo operators against a power-of-two denominator.
* src/afcjk.c (af_hint_normal_stem), src/base/ftoutln.c
(ft_contour_has), src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_vvcurveto, cff_op_hhcurveto, cff_op_hvcurveto>,
src/gxvalid/gxvcommn.c (GXV_32BIT_ALIGNMENT_VALIDATE),
src/gxvalid/gxvfeat.c (gxv_feat_setting_validate): Replace `%' with
`&' operator.
2012-02-29 Werner Lemberg <wl@gnu.org>
[autofit] Don't synchronize digit widths for light rendering mode.

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for CJK script (body). */
/* */
/* Copyright 2006-2011 by */
/* Copyright 2006-2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1610,7 +1610,7 @@
goto Exit;
}
offset = cur_len % 64;
offset = cur_len & 63;
if ( offset < 32 )
{

View File

@ -4,7 +4,7 @@
/* */
/* FreeType outline management (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
/* Copyright 1996-2008, 2010, 2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -771,7 +771,7 @@
return 1;
}
return ( n % 2 );
return n & 1;
}

View File

@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
/* Copyright 1996-2011 by */
/* Copyright 1996-2012 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1513,11 +1513,9 @@
goto Stack_Underflow;
/* if num_args isn't of the form 4n or 4n+1, */
/* we reduce it to 4n+1 */
/* we enforce it by clearing the second bit */
nargs = num_args - num_args % 4;
if ( num_args - nargs > 0 )
nargs += 1;
nargs = num_args & ~2;
if ( cff_builder_start_point( builder, x, y ) )
goto Fail;
@ -1560,11 +1558,9 @@
goto Stack_Underflow;
/* if num_args isn't of the form 4n or 4n+1, */
/* we reduce it to 4n+1 */
/* we enforce it by clearing the second bit */
nargs = num_args - num_args % 4;
if ( num_args - nargs > 0 )
nargs += 1;
nargs = num_args & ~2;
if ( cff_builder_start_point( builder, x, y ) )
goto Fail;
@ -1612,11 +1608,9 @@
goto Stack_Underflow;
/* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */
/* we reduce it to the largest one which fits */
/* we enforce it by clearing the second bit */
nargs = num_args - num_args % 4;
if ( num_args - nargs > 0 )
nargs += 1;
nargs = num_args & ~2;
args -= nargs;
if ( check_points( builder, ( nargs / 4 ) * 3 ) )

View File

@ -4,7 +4,8 @@
/* */
/* TrueTypeGX/AAT common tables validation (specification). */
/* */
/* Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* Copyright 2004, 2005, 2012 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -316,7 +317,7 @@ FT_BEGIN_HEADER
#define GXV_32BIT_ALIGNMENT_VALIDATE( a ) \
FT_BEGIN_STMNT \
{ \
if ( 0 != ( (a) % 4 ) ) \
if ( (a) & 3 ) \
FT_INVALID_OFFSET ; \
} \
FT_END_STMNT

View File

@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT feat table validation (body). */
/* */
/* Copyright 2004, 2005, 2008 by */
/* Copyright 2004, 2005, 2008, 2012 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@ -176,7 +176,7 @@
setting = FT_NEXT_USHORT( p );
/* If we have exclusive setting, the setting should be odd. */
if ( exclusive && ( setting % 2 ) == 0 )
if ( exclusive && ( setting & 1 ) == 0 )
FT_INVALID_DATA;
gxv_feat_name_index_validate( p, limit, valid );