summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2008-04-17 16:10:10 +0200
committerMichel Dänzer <michel@tungstengraphics.com>2008-04-17 16:10:10 +0200
commit9b30cc524867a0ad3d0d2227e167f4284830ab4e (patch)
tree344c6eb6b9de336448559565dfb742669bebe585
parent886af8f3849a0fcfc6b63a9695107ce26d7a6955 (diff)
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...
-rw-r--r--include/privates.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/include/privates.h b/include/privates.h
index 8d59b728f..093d17779 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -46,13 +46,20 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key);
static _X_INLINE pointer
dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
{
- PrivateRec *rec = *privates;
+ PrivateRec *rec, *prev;
pointer *ptr;
- while (rec) {
- if (rec->key == key)
- return rec->value;
- rec = rec->next;
+ for (rec = *privates, prev = NULL; rec; prev = rec, rec = rec->next) {
+ if (rec->key != key)
+ continue;
+
+ if (prev) {
+ prev->next = rec->next;
+ rec->next = *privates;
+ *privates = rec;
+ }
+
+ return rec->value;
}
ptr = dixAllocatePrivate(privates, key);