Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: pylib/gyp/input.py

Issue 235193002: gyp: use a set() in DeepDependencies for less O(n^2). (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: DeepDependency: Restore the ordering. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from compiler.ast import Const 5 from compiler.ast import Const
6 from compiler.ast import Dict 6 from compiler.ast import Dict
7 from compiler.ast import Discard 7 from compiler.ast import Discard
8 from compiler.ast import List 8 from compiler.ast import List
9 from compiler.ast import Module 9 from compiler.ast import Module
10 from compiler.ast import Node 10 from compiler.ast import Node
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 dependencies that a dependency has advertised settings should be exported 1595 dependencies that a dependency has advertised settings should be exported
1596 through the dependency for. 1596 through the dependency for.
1597 """ 1597 """
1598 1598
1599 dependencies = self.DirectDependencies(dependencies) 1599 dependencies = self.DirectDependencies(dependencies)
1600 return self._AddImportedDependencies(targets, dependencies) 1600 return self._AddImportedDependencies(targets, dependencies)
1601 1601
1602 def DeepDependencies(self, dependencies=None): 1602 def DeepDependencies(self, dependencies=None):
1603 """Returns a list of all of a target's dependencies, recursively.""" 1603 """Returns a list of all of a target's dependencies, recursively."""
1604 if dependencies == None: 1604 if dependencies == None:
1605 dependencies = [] 1605 # Using a list to get ordered output and a set to do fast "is it
1606 # already added" checks.
1607 dependencies = ([], set())
1608
1609 dependency_list, dependency_set = dependencies
1606 1610
1607 for dependency in self.dependencies: 1611 for dependency in self.dependencies:
1608 # Check for None, corresponding to the root node. 1612 # Check for None, corresponding to the root node.
1609 if dependency.ref != None and dependency.ref not in dependencies: 1613 if dependency.ref is None:
1610 dependencies.append(dependency.ref) 1614 continue
1615 if dependency.ref not in dependency_set:
1616 dependency_list.append(dependency.ref)
1617 dependency_set.add(dependency.ref)
1611 dependency.DeepDependencies(dependencies) 1618 dependency.DeepDependencies(dependencies)
1612 1619
1613 return dependencies 1620 return dependency_list
1614 1621
1615 def _LinkDependenciesInternal(self, targets, include_shared_libraries, 1622 def _LinkDependenciesInternal(self, targets, include_shared_libraries,
1616 dependencies=None, initial=True): 1623 dependencies=None, initial=True):
1617 """Returns a list of dependency targets that are linked into this target. 1624 """Returns a list of dependency targets that are linked into this target.
1618 1625
1619 This function has a split personality, depending on the setting of 1626 This function has a split personality, depending on the setting of
1620 |initial|. Outside callers should always leave |initial| at its default 1627 |initial|. Outside callers should always leave |initial| at its default
1621 setting. 1628 setting.
1622 1629
1623 When adding a target to the list of dependencies, this function will 1630 When adding a target to the list of dependencies, this function will
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2815 ValidateRunAsInTarget(target, target_dict, build_file) 2822 ValidateRunAsInTarget(target, target_dict, build_file)
2816 ValidateActionsInTarget(target, target_dict, build_file) 2823 ValidateActionsInTarget(target, target_dict, build_file)
2817 2824
2818 # Generators might not expect ints. Turn them into strs. 2825 # Generators might not expect ints. Turn them into strs.
2819 TurnIntIntoStrInDict(data) 2826 TurnIntIntoStrInDict(data)
2820 2827
2821 # TODO(mark): Return |data| for now because the generator needs a list of 2828 # TODO(mark): Return |data| for now because the generator needs a list of
2822 # build files that came in. In the future, maybe it should just accept 2829 # build files that came in. In the future, maybe it should just accept
2823 # a list, and not the whole data dict. 2830 # a list, and not the whole data dict.
2824 return [flat_list, targets, data] 2831 return [flat_list, targets, data]
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698