nobug: Use sets for slavenames, buildernames, etc. to speed up checkconfig. r=rail,jlin
authorChris AtLee <catlee@mozilla.com>
Thu, 07 Nov 2013 13:04:26 -0500
changeset 901 7189e0a6bead73b39245b883264b29e369800efb
parent 895 b4673f1f2a866400ed43e7c2b14607a610090f62
child 902 75bfc678d50593d5fa7ffb6d2defa6c8021d7d11
child 930 c572b4d8d6c839d621018036c403e435dfa1fa58
push id667
push usercatlee@mozilla.com
push dateThu, 07 Nov 2013 18:04:47 +0000
reviewersrail, jlin
nobug: Use sets for slavenames, buildernames, etc. to speed up checkconfig. r=rail,jlin
master/buildbot/master.py
--- a/master/buildbot/master.py
+++ b/master/buildbot/master.py
@@ -761,19 +761,19 @@ class BuildMaster(service.MultiService):
         errmsg = "c['schedulers'] must be a list of Scheduler instances"
         assert isinstance(schedulers, (list, tuple)), errmsg
         for s in schedulers:
             assert interfaces.IScheduler(s, None), errmsg
         assert isinstance(status, (list, tuple))
         for s in status:
             assert interfaces.IStatusReceiver(s, None)
 
-        slavenames = [s.slavename for s in slaves]
-        buildernames = []
-        dirnames = []
+        slavenames = set(s.slavename for s in slaves)
+        buildernames = set()
+        dirnames = set()
 
         # convert builders from objects to config dictionaries
         builders_dicts = []
         for b in builders:
             if isinstance(b, BuilderConfig):
                 builders_dicts.append(b.getConfigDict())
             elif type(b) is dict:
                 builders_dicts.append(b)
@@ -787,17 +787,17 @@ class BuildMaster(service.MultiService):
                                  % (b['name'], b['slavename']))
             for n in b.get('slavenames', []):
                 if n not in slavenames:
                     raise ValueError("builder %s uses undefined slave %s" \
                                      % (b['name'], n))
             if b['name'] in buildernames:
                 raise ValueError("duplicate builder name %s"
                                  % b['name'])
-            buildernames.append(b['name'])
+            buildernames.add(b['name'])
 
             # sanity check name (BuilderConfig does this too)
             if b['name'].startswith("_"):
                 errmsg = ("builder names must not start with an "
                           "underscore: " + b['name'])
                 log.err(errmsg)
                 raise ValueError(errmsg)
 
@@ -806,19 +806,19 @@ class BuildMaster(service.MultiService):
             b.setdefault('builddir', safeTranslate(b['name']))
             b.setdefault('slavebuilddir', b['builddir'])
             b.setdefault('buildHorizon', buildHorizon)
             b.setdefault('logHorizon', logHorizon)
             b.setdefault('eventHorizon', eventHorizon)
             if b['builddir'] in dirnames:
                 raise ValueError("builder %s reuses builddir %s"
                                  % (b['name'], b['builddir']))
-            dirnames.append(b['builddir'])
+            dirnames.add(b['builddir'])
 
-        unscheduled_buildernames = buildernames[:]
+        unscheduled_buildernames = set(buildernames)
         schedulernames = []
         for s in schedulers:
             for b in s.listBuilderNames():
                 # Skip checks for builders in multimaster mode
                 if not multiMaster:
                     assert b in buildernames, \
                            "%s uses unknown builder %s" % (s, b)
                 if b in unscheduled_buildernames: