Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce the number of pruning operations #2881

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Dec 7, 2023

Instead of checking a path against the entire list of paths every time, we only check against the list of already accepted paths.

Instead of checking a path against the entire list of paths every time,
we only check against the list of already accepted paths.
@Geal Geal requested a review from a team as a code owner December 7, 2023 11:27
Copy link

changeset-bot bot commented Dec 7, 2023

⚠️ No Changeset found

Latest commit: f8e7b10

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for apollo-federation-docs canceled.

Name Link
🔨 Latest commit f8e7b10
🔍 Latest deploy log https://app.netlify.com/sites/apollo-federation-docs/deploys/6571ac1723196400095960aa

Copy link

codesandbox-ci bot commented Dec 7, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@Geal
Copy link
Contributor Author

Geal commented Dec 7, 2023

there's another potnetial optimization here: makingownPathIds a Set instead of an array:

readonly ownPathIds: readonly string[],

Since it is only used to be filled and the only part where it is read is in isOverridenBy`:

isOverriddenBy(otherPath: GraphPath<TTrigger, RV, TNullEdge>): boolean {
for (const overriddingId of this.props.overriddingPathIds) {
if (otherPath.props.ownPathIds.includes(overriddingId)) {
return true;
}
}
return false;
}

@Geal
Copy link
Contributor Author

Geal commented Dec 7, 2023

I am not sure this PR is correct. In markOverriding:

markOverridding(otherOptions: GraphPath<TTrigger, RV, TNullEdge>[][]): {
thisPath: GraphPath<TTrigger, RV, TNullEdge>,
otherOptions: GraphPath<TTrigger, RV, TNullEdge>[][],
} {
const newId = uuidv4();
return {
thisPath: new GraphPath({
...this.props,
ownPathIds: this.props.ownPathIds.concat(newId),
}),
otherOptions: otherOptions.map((paths) => paths.map((p) => new GraphPath({
...p.props,
overriddingPathIds: p.props.overriddingPathIds.concat(newId),
}))),
};
}

we add the newId to thisPath.ownPathIds but we add it to overridingPathIds in the paths under otherOptions. So I don't think there's a transitive dependency here where A overrides B and B overrides C would mean A overrides C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant