diff mbox series

[v2,06/11] runqueue: optimize construction of rev_prio_map

Message ID 20260827201720.698482-8-chris.laplante@agilent.com
State New
Headers show
Series runqueue correctness fixes, optimizations, and cleanups | expand

Commit Message

chris.laplante@agilent.com Aug. 27, 2026, 8:17 p.m. UTC
From: Chris Laplante <chris.laplante@agilent.com>

Make this an O(N) operation instead of O(N^2), where N = size of
runtaskentries map

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 lib/bb/runqueue.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 5b92e405e..54e1066a9 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -287,9 +287,10 @@  class RunQueueScheduler(object):
                 return tid
 
         if not self.rev_prio_map:
-            self.rev_prio_map = {}
-            for tid in self.rqdata.runtaskentries:
-                self.rev_prio_map[tid] = self.prio_map.index(tid)
+            self.rev_prio_map = {
+                tid: priority
+                for priority, tid in enumerate(self.prio_map)
+            }
 
         best = None
         bestprio = None