[PATCH xserver] dix: cache ResourceClientBits() value

Olivier Fourdan ofourdan at redhat.com
Fri Nov 30 12:15:24 UTC 2018


That saves running the same loop over and over.

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 dix/resource.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dix/resource.c b/dix/resource.c
index b6ef99f10..e39df7773 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -620,7 +620,12 @@ ilog2(int val)
 unsigned int
 ResourceClientBits(void)
 {
-    return (ilog2(LimitClients));
+    static int cached = 0;
+
+    if (cached == 0)
+      cached = ilog2(LimitClients);
+
+    return cached;
 }
 
 /*****************
-- 
2.19.2



More information about the xorg-devel mailing list