Optimize dixLookupPrivate for repeated lookups of the same private.

This gives me a 20% speedup for EXA text rendering, though I still seem to burn
quite a lot of cycles in here...
This commit is contained in:
Michel Dänzer 2008-04-17 16:10:10 +02:00
parent 886af8f384
commit 9b30cc5248

View File

@ -46,13 +46,20 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key);
static _X_INLINE pointer static _X_INLINE pointer
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key) dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
{ {
PrivateRec *rec = *privates; PrivateRec *rec, *prev;
pointer *ptr; pointer *ptr;
while (rec) { for (rec = *privates, prev = NULL; rec; prev = rec, rec = rec->next) {
if (rec->key == key) if (rec->key != key)
continue;
if (prev) {
prev->next = rec->next;
rec->next = *privates;
*privates = rec;
}
return rec->value; return rec->value;
rec = rec->next;
} }
ptr = dixAllocatePrivate(privates, key); ptr = dixAllocatePrivate(privates, key);