Bug 1538625 [wpt PR 15978] - Avoid referring to self._data and self._path_hash everywhere, a=testonly
authorSam Sneddon <me@gsnedders.com>
Thu, 18 Apr 2019 10:13:43 +0000
changeset 470549 1267e59b64193a4ee3607d22c1d7b9213b39a061
parent 470548 dbec48269d69acdaa6059139c37a6754239e4f5e
child 470550 84c9ed88a5e5f3fea27657a7cb62ee8b2dc974f7
push id112872
push userjames@hoppipolla.co.uk
push dateTue, 23 Apr 2019 14:15:53 +0000
treeherdermozilla-inbound@fc657d55eb97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1538625, 15978
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1538625 [wpt PR 15978] - Avoid referring to self._data and self._path_hash everywhere, a=testonly Automatic update from web-platform-tests Bring py36-flake8.ini back inline with py27-flake8.ini -- wpt-commits: f23b94cdedb7d632d6616fab6f5c244dcc9ddb11 wpt-pr: 15978
testing/web-platform/tests/tools/manifest/manifest.py
testing/web-platform/tests/tools/py36-flake8.ini
--- a/testing/web-platform/tests/tools/manifest/manifest.py
+++ b/testing/web-platform/tests/tools/manifest/manifest.py
@@ -266,88 +266,93 @@ class Manifest(object):
         constructed in the case we are not updating a path, but the absence of an item from
         the iterator may be used to remove defunct entries from the manifest."""
         reftest_nodes = []
         seen_files = set()
 
         changed = False
         reftest_changes = False
 
-        prev_files = self._data.paths()
+        # Create local variable references to these dicts so we avoid the
+        # attribute access in the hot loop below
+        path_hash = self._path_hash
+        data = self._data
+
+        prev_files = data.paths()
 
         reftest_types = ("reftest", "reftest_node")
 
         for source_file, update in tree:
             if not update:
                 rel_path = source_file
                 seen_files.add(rel_path)
-                assert rel_path in self._path_hash
-                old_hash, old_type = self._path_hash[rel_path]
+                assert rel_path in path_hash
+                old_hash, old_type = path_hash[rel_path]
                 if old_type in reftest_types:
-                    manifest_items = self._data[old_type][rel_path]
+                    manifest_items = data[old_type][rel_path]
                     reftest_nodes.extend((item, old_hash) for item in manifest_items)
             else:
                 rel_path = source_file.rel_path
                 seen_files.add(rel_path)
 
                 file_hash = source_file.hash
 
-                is_new = rel_path not in self._path_hash
+                is_new = rel_path not in path_hash
                 hash_changed = False
 
                 if not is_new:
-                    old_hash, old_type = self._path_hash[rel_path]
+                    old_hash, old_type = path_hash[rel_path]
                     if old_hash != file_hash:
                         new_type, manifest_items = source_file.manifest_items()
                         hash_changed = True
                         if new_type != old_type:
-                            del self._data[old_type][rel_path]
+                            del data[old_type][rel_path]
                             if old_type in reftest_types:
                                 reftest_changes = True
                     else:
                         new_type = old_type
                         if old_type in reftest_types:
-                            manifest_items = self._data[old_type][rel_path]
+                            manifest_items = data[old_type][rel_path]
                 else:
                     new_type, manifest_items = source_file.manifest_items()
 
                 if new_type in reftest_types:
                     reftest_nodes.extend((item, file_hash) for item in manifest_items)
                     if is_new or hash_changed:
                         reftest_changes = True
                 elif is_new or hash_changed:
-                    self._data[new_type][rel_path] = set(manifest_items)
+                    data[new_type][rel_path] = set(manifest_items)
 
                 if is_new or hash_changed:
-                    self._path_hash[rel_path] = (file_hash, new_type)
+                    path_hash[rel_path] = (file_hash, new_type)
                     changed = True
 
         deleted = prev_files - seen_files
         if deleted:
             changed = True
             for rel_path in deleted:
-                if rel_path in self._path_hash:
-                    _, old_type = self._path_hash[rel_path]
+                if rel_path in path_hash:
+                    _, old_type = path_hash[rel_path]
                     if old_type in reftest_types:
                         reftest_changes = True
-                    del self._path_hash[rel_path]
+                    del path_hash[rel_path]
                     try:
-                        del self._data[old_type][rel_path]
+                        del data[old_type][rel_path]
                     except KeyError:
                         pass
                 else:
-                    for test_data in itervalues(self._data):
+                    for test_data in itervalues(data):
                         if rel_path in test_data:
                             del test_data[rel_path]
 
         if reftest_changes:
             reftests, reftest_nodes, changed_hashes = self._compute_reftests(reftest_nodes)
-            self._data["reftest"].data = reftests
-            self._data["reftest_node"].data = reftest_nodes
-            self._path_hash.update(changed_hashes)
+            data["reftest"].data = reftests
+            data["reftest_node"].data = reftest_nodes
+            path_hash.update(changed_hashes)
 
         return changed
 
     def _compute_reftests(self, reftest_nodes):
         self._reftest_nodes_by_url = {}
         has_inbound = set()
         for item, _ in reftest_nodes:
             for ref_url, ref_type in item.references:
--- a/testing/web-platform/tests/tools/py36-flake8.ini
+++ b/testing/web-platform/tests/tools/py36-flake8.ini
@@ -10,17 +10,18 @@ select = E,W,F,N
 # E303: too many blank lines (3)
 # E305: expected 2 blank lines after end of function or class
 # E402: module level import not at top of file
 # E731: do not assign a lambda expression, use a def
 # W504: line break after binary operator
 # W605: invalid escape sequence
 # N801: class names should use CapWords convention
 # N802: function name should be lowercase
-ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W504,W605,N801,N802
+# N806: variable in function should be lowercase
+ignore = E128,E129,E226,E231,E251,E265,E302,E303,E305,E402,E731,W504,W605,N801,N802,N806
 exclude =
     .tox,
     pywebsocket,
     third_party,
     wptrunner,
     wptserve/docs/conf.py,
     wptserve/tests/functional/docroot/invalid.py
 max-line-length = 141