... |
... |
@@ -169,7 +169,6 @@ gblender_init( GBlender blender, |
169
|
169
|
blender->stat_lookups = 0;
|
170
|
170
|
blender->stat_clashes = 0;
|
171
|
171
|
blender->stat_keys = 0;
|
172
|
|
- blender->stat_clears = 0;
|
173
|
172
|
#endif
|
174
|
173
|
}
|
175
|
174
|
|
... |
... |
@@ -264,37 +263,28 @@ gblender_lookup( GBlender blender, |
264
|
263
|
GBlenderPixel background,
|
265
|
264
|
GBlenderPixel foreground )
|
266
|
265
|
{
|
267
|
|
- int idx, idx0;
|
268
|
|
- GBlenderKey key;
|
|
266
|
+ unsigned int idx;
|
|
267
|
+ GBlenderKey key;
|
269
|
268
|
|
270
|
269
|
#ifdef GBLENDER_STATS
|
271
|
270
|
blender->stat_hits--;
|
272
|
271
|
blender->stat_lookups++;
|
273
|
272
|
#endif
|
274
|
273
|
|
275
|
|
- idx0 = ( background + foreground*63 ) & (GBLENDER_KEY_COUNT-1);
|
276
|
|
- idx = idx0;
|
277
|
|
- do
|
278
|
|
- {
|
279
|
|
- key = blender->keys + idx;
|
|
274
|
+ idx = ( background ^ foreground * 7 ) % (GBLENDER_KEY_COUNT-1);
|
280
|
275
|
|
281
|
|
- if ( key->cells == NULL )
|
282
|
|
- goto NewNode;
|
|
276
|
+ key = blender->keys + idx;
|
283
|
277
|
|
284
|
|
- if ( key->background == background &&
|
285
|
|
- key->foreground == foreground )
|
286
|
|
- goto Exit;
|
|
278
|
+ if ( key->cells == NULL )
|
|
279
|
+ goto NewNode;
|
287
|
280
|
|
288
|
|
- idx = (idx+1) & (GBLENDER_KEY_COUNT-1);
|
289
|
|
- }
|
290
|
|
- while ( idx != idx0 );
|
|
281
|
+ if ( key->background == background &&
|
|
282
|
+ key->foreground == foreground )
|
|
283
|
+ goto Exit;
|
291
|
284
|
|
292
|
|
- /* the cache is full, clear it completely
|
293
|
|
- */
|
294
|
285
|
#ifdef GBLENDER_STATS
|
295
|
|
- blender->stat_clears++;
|
|
286
|
+ blender->stat_clashes++;
|
296
|
287
|
#endif
|
297
|
|
- gblender_clear( blender );
|
298
|
288
|
|
299
|
289
|
NewNode:
|
300
|
290
|
key->background = background;
|
... |
... |
@@ -309,9 +299,6 @@ NewNode: |
309
|
299
|
#endif
|
310
|
300
|
|
311
|
301
|
Exit:
|
312
|
|
-#ifdef GBLENDER_STATS
|
313
|
|
- blender->stat_clashes += ( idx - idx0 ) & (GBLENDER_KEY_COUNT-1);
|
314
|
|
-#endif
|
315
|
302
|
return key->cells;
|
316
|
303
|
}
|
317
|
304
|
|
... |
... |
@@ -360,7 +347,7 @@ gblender_lookup_channel( GBlender blender, |
360
|
347
|
unsigned int background,
|
361
|
348
|
unsigned int foreground )
|
362
|
349
|
{
|
363
|
|
- int idx, idx0;
|
|
350
|
+ unsigned idx;
|
364
|
351
|
unsigned short backfore = (unsigned short)((foreground << 8) | background);
|
365
|
352
|
GBlenderChanKey key;
|
366
|
353
|
|
... |
... |
@@ -369,28 +356,19 @@ gblender_lookup_channel( GBlender blender, |
369
|
356
|
blender->stat_lookups++;
|
370
|
357
|
#endif
|
371
|
358
|
|
372
|
|
- idx0 = ( background + foreground*17 ) & (GBLENDER_KEY_COUNT-1);
|
373
|
|
- idx = idx0;
|
374
|
|
- do
|
375
|
|
- {
|
376
|
|
- key = (GBlenderChanKey)blender->keys + idx;
|
|
359
|
+ idx = ( background ^ foreground * 7 ) % (GBLENDER_KEY_COUNT-1);
|
377
|
360
|
|
378
|
|
- if ( key->index < 0 )
|
379
|
|
- goto NewNode;
|
|
361
|
+ key = (GBlenderChanKey)blender->keys + idx;
|
380
|
362
|
|
381
|
|
- if ( key->backfore == backfore )
|
382
|
|
- goto Exit;
|
|
363
|
+ if ( key->index < 0 )
|
|
364
|
+ goto NewNode;
|
383
|
365
|
|
384
|
|
- idx = (idx+1) & (GBLENDER_KEY_COUNT-1);
|
385
|
|
- }
|
386
|
|
- while ( idx != idx0 );
|
|
366
|
+ if ( key->backfore == backfore )
|
|
367
|
+ goto Exit;
|
387
|
368
|
|
388
|
|
- /* the cache is full, clear it completely
|
389
|
|
- */
|
390
|
369
|
#ifdef GBLENDER_STATS
|
391
|
|
- blender->stat_clears++;
|
|
370
|
+ blender->stat_clashes++;
|
392
|
371
|
#endif
|
393
|
|
- gblender_clear( blender );
|
394
|
372
|
|
395
|
373
|
NewNode:
|
396
|
374
|
key->backfore = backfore;
|
... |
... |
@@ -403,9 +381,6 @@ NewNode: |
403
|
381
|
#endif
|
404
|
382
|
|
405
|
383
|
Exit:
|
406
|
|
-#ifdef GBLENDER_STATS
|
407
|
|
- blender->stat_clashes += ( idx - idx0 ) & (GBLENDER_KEY_COUNT-1);
|
408
|
|
-#endif
|
409
|
384
|
return (unsigned char*)blender->cells + key->index;
|
410
|
385
|
}
|
411
|
386
|
|
... |
... |
@@ -429,7 +404,6 @@ gblender_dump_stats( GBlender blender ) |
429
|
404
|
blender->stat_lookups - blender->stat_keys,
|
430
|
405
|
blender->stat_lookups );
|
431
|
406
|
printf( " Clashes: %ld\n", blender->stat_clashes );
|
432
|
|
- printf( " Keys used: %ld\n Caches full: %ld\n",
|
433
|
|
- blender->stat_keys, blender->stat_clears );
|
|
407
|
+ printf( " Keys used: %ld\n", blender->stat_keys );
|
434
|
408
|
}
|
435
|
409
|
#endif |