Bug 1355630 - Extract set declaration to member variable; r?chmanchester draft
authorGregory Szorc <gps@mozilla.com>
Tue, 11 Apr 2017 16:13:07 -0700
changeset 560843 bd68e0bdb017b7e3d64a0b83441488e120c641a8
parent 560842 58739c053019a4dc56cfb4e4255fa89bcaeae2c0
child 560844 ba9aaf0ded032bcc2e9d92cba45b9c9e332629e7
child 560848 9abbb5086ed7ae32e745ef3696a54a59cbcf800c
push id53552
push userbmo:gps@mozilla.com
push dateTue, 11 Apr 2017 23:50:02 +0000
reviewerschmanchester
bugs1355630
milestone55.0a1
Bug 1355630 - Extract set declaration to member variable; r?chmanchester The variable is deterministic. We can call this function thousands of times. There's no need to populate the set on every invocation. MozReview-Commit-ID: 1N9JE980Npt
python/mozbuild/mozbuild/frontend/reader.py
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -1393,24 +1393,28 @@ class BuildReader(object):
 
             if not any([flags.test_tags, flags.test_files, flags.test_flavors]):
                 flags += self.test_defaults_for_path(ctxs)
 
             r[path] = flags
 
         return r
 
+    # This names the context keys that will end up emitting a test
+    # manifest.
+    TEST_MANIFEST_CONTEXTS = set(
+        ['%s_MANIFESTS' % key for key in TEST_MANIFESTS] +
+        ['%s_MANIFESTS' % flavor.upper() for flavor in REFTEST_FLAVORS] +
+        ['%s_MANIFESTS' % flavor.upper().replace('-', '_') for flavor in
+         WEB_PLATFORM_TESTS_FLAVORS]
+    )
+
     def test_defaults_for_path(self, ctxs):
-        # This names the context keys that will end up emitting a test
-        # manifest.
-        test_manifest_contexts = set(
-            ['%s_MANIFESTS' % key for key in TEST_MANIFESTS] +
-            ['%s_MANIFESTS' % flavor.upper() for flavor in REFTEST_FLAVORS] +
-            ['%s_MANIFESTS' % flavor.upper().replace('-', '_') for flavor in WEB_PLATFORM_TESTS_FLAVORS]
-        )
+        # Alias to local because used in tight loop.
+        test_manifest_contexts = self.TEST_MANIFEST_CONTEXTS
 
         result_context = Files(Context())
         for ctx in ctxs:
             for key in ctx:
                 if key not in test_manifest_contexts:
                     continue
                 for paths, obj in ctx[key]:
                     if isinstance(paths, tuple):