Chromium Code Reviews| Index: Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py |
| diff --git a/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py b/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py |
| index 641572f60c66de9f476288a77e651dcbadbbcdaa..ae3b853793c066aa13bf5eb83439b152abe8d3ea 100644 |
| --- a/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py |
| +++ b/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py |
| @@ -30,6 +30,8 @@ |
| for layout tests. |
| """ |
| +from collections import defaultdict |
| + |
| import logging |
| import re |
| @@ -563,9 +565,26 @@ class TestExpectationsModel(object): |
| def merge_model(self, other): |
| self._merge_test_map(self._test_to_expectations, other._test_to_expectations) |
| + # This code is n^2 in the number of tests per line. Cache the output |
|
Dirk Pranke
2015/06/15 22:50:59
"This code" is a bit ambiguous.
It's merge_expec
ojan
2015/06/17 17:16:53
Done
|
| + # of merge_expectation_lines so that we only call that n^2 in the number |
| + # of *lines*. |
| + merge_lines_cache = defaultdict(dict) |
| + |
| for test, line in other._test_to_expectation_line.items(): |
| if test in self._test_to_expectation_line: |
| - line = TestExpectationLine.merge_expectation_lines(self._test_to_expectation_line[test], line, model_all_expectations=False) |
| + self_line = self._test_to_expectation_line[test] |
| + |
| + cached_line = None |
| + if self_line in merge_lines_cache: |
| + cached_line = merge_lines_cache[self_line].get(line) |
| + |
| + if cached_line: |
| + line = cached_line |
| + else: |
| + new_line = TestExpectationLine.merge_expectation_lines(self_line, line, model_all_expectations=False) |
| + merge_lines_cache[self_line][line] = new_line |
| + line = new_line |
|
Dirk Pranke
2015/06/15 22:50:59
Can you rewrite lines 577-586 as:
if line not in
ojan
2015/06/17 17:16:53
That's much better. I didn't do exactly this, but
|
| + |
| self._test_to_expectation_line[test] = line |
| self._merge_dict_of_sets(self._expectation_to_tests, other._expectation_to_tests) |