That saves running the same loop over and over.

Signed-off-by: Olivier Fourdan <ofour...@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

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to