[xserver] dix: cache ResourceClientBits() value

Submitted by Olivier Fourdan on Nov. 30, 2018, 12:15 p.m.

Details

Message ID 20181130121524.26831-1-ofourdan@redhat.com
State New
Series "dix: cache ResourceClientBits() value"
Headers show

Commit Message

Olivier Fourdan Nov. 30, 2018, 12:15 p.m.
That saves running the same loop over and over.

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

Patch hide | download patch | download mbox

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;
 }
 
 /*****************