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

Allow TraverseCallback to bail out early #1034

Merged
merged 3 commits into from May 8, 2019

Conversation

Gerrit0
Copy link
Collaborator

@Gerrit0 Gerrit0 commented May 7, 2019

It is used in getChildByName when searching for a reflection by name, which led to always searching all children, which is especially problematic for any deeply nested structures.

Improves convert time by 25% on the monaco.d.ts file in #975

It is used in getChildByName to search children, which led to *always* searching all children, which is especially problematic for any deeply nested structures.

Improves convert time by 25% on the monaco.d.ts file in #975
@Gerrit0 Gerrit0 requested a review from aciccarello May 7, 2019 22:35
Copy link
Collaborator

@aciccarello aciccarello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just have a question about if we need to .slice()

this.children.slice().forEach((child: DeclarationReflection) => {
callback(child, TraverseProperty.Children);
});
for (const child of toArray(this.children).slice()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to slice if you are already doing toArray?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I assumed toArray just returned the input if it was an array, but apparently it copies the array. Will remove.

@Gerrit0 Gerrit0 merged commit 14d23b8 into master May 8, 2019
@Gerrit0 Gerrit0 deleted the improve-traverse-performance branch May 8, 2019 21:32
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

2 participants