Hallo,
I can understand that for a loop like
int k = 6;
do k--; while (k);
may and should not be produced any code by the compiler. Speed and size optimizations do this.
But the dowhile loop in the following function
//#pragma optimize(none)
long HTfreePos(HTAB *ht, long keylng)
{
short int i;
long oldsize, p;
do {
//#pragma optimize()
p = keylng & BITS[ht->bits];
if ( NULL == ht->kvt[p].key ) return p; // 1. Versuch und Treffer!
p = (p + FIRSTJMP) & BITS[ht->bits];
if ( NULL == ht->kvt[p].key ) return p; // 2. Versuch und Treffer!
p = (p + SECONDJMP) & BITS[ht->bits];
if ( NULL == ht->kvt[p].key ) return p; // 3. Versuch und Treffer!
// Wir verdoppeln das Dictionary
if ( 31 > ht->bits ) {
ht->bits++;
oldsize = ht->size;
ht->size <<= 1;
ht->kvt = realloc(ht->kvt, ht->size*sizeof(KV));
if ( !ht) HTerror("could'nt allocate memory");
for ( i = 0; i < oldsize; i++ )
if ( ht->kvt.hsh & BITS[ht->bits] != i ) {
ht->kvt[i + oldsize].hsh = ht->kvt.hsh;
ht->kvt[i + oldsize].key = ht->kvt.key;
ht->kvt[i + oldsize].val = ht->kvt.val;
ht->kvt.hsh = -1;
ht->kvt.key = ht->kvt.val = NULL;
} else {
ht->kvt[i + oldsize].hsh = -1;
ht->kvt[i + oldsize].key = ht->kvt.val = NULL;
}
}
} while (1);
}
is ignored too. This is in my opinion a bug!
Question: With the pragmas enabled in the above code, when is optimization again switched on? Directly after the 'do' or at the end of the function?
czerny