Mail Archives: pgcc/1999/09/26/20:54:11
On Sun, Sep 26, 1999 at 11:07:37PM +0100, Vincent Diepeveen wrote:
>
> The general patterns sure are hard to rewrite:
>
> if( GENERAL PATTERN ) {
> if( PATTERN l PATTERN l PATTERN )
> s += SCORE_XXXX;
>
> if( PATTERN l PATTERN l PATTERN )
> s += SCORE_YXXX;
>
> if( PATTERN l PATTERN l PATTERN )
> s += SCORE_XXXX;
> }
>
> So to fall through i would have to do next:
> if( !GENERALPATTERN ) {
> // nothing
> }
> else {
> if( PATTERN l PATTERN l PATTERN )
> s += SCORE_XXXX;
>
> if( PATTERN l PATTERN l PATTERN )
> s += SCORE_YXXX;
>
> if( PATTERN l PATTERN l PATTERN )
> s += SCORE_XXXX;
> }
>
> Question: is above rewrite smart?
I would be surprised if the rewrite results in different code.
pgcc/gcc is smart enough to see that both are equivalent.
In fact, I just tried it in a small example, and the generated
code was the same in both cases.
So you won't get faster code, but at least you don't have to
worry about rewriting your code in a smart way that would make
it more difficult to understand and maintain.
Ronald
- Raw text -