Skip to content

Commit

Permalink
Parse CIJob maps once
Browse files Browse the repository at this point in the history
Move the `parse` operation out of the loop across OS and SDK
combinations. Change from a factory to a static method that returns a
record with the two fields that get parsed out of the yaml map at this
level. The `parse` method creates a copy of the map, which shouldn't be
necessary to do more than once.
  • Loading branch information
natebosch committed Aug 7, 2024
1 parent 62562fe commit e0f60b3
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions mono_repo/lib/src/package_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,18 @@ class PackageConfig {
osConfigUsed = true;
}

final (:description, :tasks) =
CIJob.parse(job as Object, flavor: flavor);
for (var sdk in jobSdks) {
for (var os in jobOses) {
jobs.add(
CIJob.parse(
CIJob(
os,
relativePath,
sdk,
stage.name,
job as Object,
tasks,
description: description,
flavor: flavor,
),
);
Expand Down Expand Up @@ -255,11 +258,7 @@ class CIJob implements HasStageName {
'Should have caught bad sdk value `$sdk` before here!',
);

factory CIJob.parse(
String os,
String package,
String sdk,
String stageName,
static ({String? description, List<Task> tasks}) parse(
Object yaml, {
required PackageFlavor flavor,
}) {
Expand All @@ -272,14 +271,9 @@ class CIJob implements HasStageName {
withoutDescription = yaml;
}
final tasks = Task.parseTaskOrGroup(flavor, withoutDescription);
return CIJob(
os,
package,
sdk,
stageName,
tasks,
return (
tasks: tasks,
description: description,
flavor: flavor,
);
}

Expand Down

0 comments on commit e0f60b3

Please sign in to comment.