Skip to content

Commit ee414e3

Browse files
[CI] Refactor out some early exits in compute_projects
I have a habit of using early exits given it is in the LLVM coding standards, but most of the early exits used within this script were trivial and actually adding complexity. These are all instances where we only perform one operation after the early exit, so removing the early exit means less lines of code and arguably more readable code. Reviewers: DavidSpickett, tstellar, cmtice, lnihlen Reviewed By: DavidSpickett Pull Request: #143478
1 parent f2eb5d4 commit ee414e3

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

.ci/compute_projects.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,11 @@ def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
135135
while current_projects_count != len(projects_with_dependents):
136136
current_projects_count = len(projects_with_dependents)
137137
for project in list(projects_with_dependents):
138-
if project not in PROJECT_DEPENDENCIES:
139-
continue
140-
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
138+
if project in PROJECT_DEPENDENCIES:
139+
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
141140
for runtime in runtimes:
142-
if runtime not in PROJECT_DEPENDENCIES:
143-
continue
144-
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
141+
if runtime in PROJECT_DEPENDENCIES:
142+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
145143
return projects_with_dependents
146144

147145

@@ -187,18 +185,16 @@ def _compute_projects_to_build(
187185
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
188186
check_targets = set()
189187
for project_to_test in projects_to_test:
190-
if project_to_test not in PROJECT_CHECK_TARGETS:
191-
continue
192-
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
188+
if project_to_test in PROJECT_CHECK_TARGETS:
189+
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
193190
return check_targets
194191

195192

196193
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
197194
runtimes_to_test = set()
198195
for modified_project in modified_projects:
199-
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST:
200-
continue
201-
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
196+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST:
197+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
202198
return _exclude_projects(runtimes_to_test, platform)
203199

204200

@@ -207,11 +203,10 @@ def _compute_runtimes_to_test_needs_reconfig(
207203
) -> Set[str]:
208204
runtimes_to_test = set()
209205
for modified_project in modified_projects:
210-
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
211-
continue
212-
runtimes_to_test.update(
213-
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
214-
)
206+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
207+
runtimes_to_test.update(
208+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
209+
)
215210
return _exclude_projects(runtimes_to_test, platform)
216211

217212

0 commit comments

Comments
 (0)