bitbake: runqueue.py: Convert depends variable to use sets
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 27 Jun 2012 10:04:48 +0000 (11:04 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 28 Jun 2012 15:32:57 +0000 (16:32 +0100)
This gives some small performance gains and sets the scene for other
improvements by removing the need for duplicate detection code.

(Bitbake rev: 6fd723479e8d49227fd58040b3485c1d5afc4bc5)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/runqueue.py

index e09e8c8..c45287d 100644 (file)
@@ -409,7 +409,7 @@ class RunQueueData:
                 for taskname in tasknames:
                     taskid = taskData.gettask_id_fromfnid(depdata, taskname)
                     if taskid is not None:
-                        depends.append(taskid)
+                        depends.add(taskid)
 
         def add_runtime_dependencies(depids, tasknames, depends):
             for depid in depids:
@@ -421,10 +421,10 @@ class RunQueueData:
                 for taskname in tasknames:
                     taskid = taskData.gettask_id_fromfnid(depdata, taskname)
                     if taskid is not None:
-                        depends.append(taskid)
+                        depends.add(taskid)
 
         for task in xrange(len(taskData.tasks_name)):
-            depends = []
+            depends = set()
             recrdepends = []
             fnid = taskData.tasks_fnid[task]
             fn = taskData.fn_index[fnid]
@@ -437,7 +437,7 @@ class RunQueueData:
                 # Resolve task internal dependencies
                 #
                 # e.g. addtask before X after Y
-                depends = taskData.tasks_tdepends[task]
+                depends = set(taskData.tasks_tdepends[task])
 
                 # Resolve 'deptask' dependencies
                 #
@@ -470,7 +470,7 @@ class RunQueueData:
                             taskid = taskData.gettask_id_fromfnid(depdata, idependtask)
                             if taskid is None:
                                 bb.msg.fatal("RunQueue", "Task %s in %s depends upon non-existent task %s in %s" % (taskData.tasks_name[task], fn, idependtask, dep))
-                            depends.append(taskid)
+                            depends.add(taskid)
                             if depdata != fnid:
                                 tdepends_fnid[fnid].add(taskid)
                 irdepends = taskData.tasks_irdepends[task]
@@ -482,7 +482,7 @@ class RunQueueData:
                             taskid = taskData.gettask_id_fromfnid(depdata, idependtask)
                             if taskid is None:
                                 bb.msg.fatal("RunQueue", "Task %s in %s rdepends upon non-existent task %s in %s" % (taskData.tasks_name[task], fn, idependtask, dep))
-                            depends.append(taskid)
+                            depends.add(taskid)
                             if depdata != fnid:
                                 tdepends_fnid[fnid].add(taskid)
 
@@ -499,16 +499,12 @@ class RunQueueData:
 
                 # Rmove all self references
                 if task in depends:
-                    newdep = []
                     logger.debug(2, "Task %s (%s %s) contains self reference! %s", task, taskData.fn_index[taskData.tasks_fnid[task]], taskData.tasks_name[task], depends)
-                    for dep in depends:
-                        if task != dep:
-                            newdep.append(dep)
-                    depends = newdep
+                    depends.remove(task)
 
             self.runq_fnid.append(taskData.tasks_fnid[task])
             self.runq_task.append(taskData.tasks_name[task])
-            self.runq_depends.append(set(depends))
+            self.runq_depends.append(depends)
             self.runq_revdeps.append(set())
             self.runq_hash.append("")