Skip to content

Remove reflection perf #890

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

Merged
merged 3 commits into from
Nov 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions src/lib/converter/plugins/CommentPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ export class CommentPlugin extends ConverterComponent {

if (this.hidden) {
const project = context.project;
this.hidden.forEach((reflection) => {
CommentPlugin.removeReflection(project, reflection);
});
CommentPlugin.removeReflections(project, this.hidden);
}
}

Expand Down Expand Up @@ -314,11 +312,27 @@ export class CommentPlugin extends ConverterComponent {
}
}

/**
* Remove the specified reflections from the project.
*/
static removeReflections(project: ProjectReflection, reflections: Reflection[]) {
const deletedIds: number[] = [];
reflections.forEach((reflection) => {
CommentPlugin.removeReflection(project, reflection, deletedIds);
});

for (let key in project.symbolMapping) {
if (project.symbolMapping.hasOwnProperty(key) && deletedIds.indexOf(project.symbolMapping[key]) !== -1) {
delete project.symbolMapping[key];
}
}
}

/**
* Remove the given reflection from the project.
*/
static removeReflection(project: ProjectReflection, reflection: Reflection) {
reflection.traverse((child) => CommentPlugin.removeReflection(project, child));
private static removeReflection(project: ProjectReflection, reflection: Reflection, deletedIds: number[]) {
reflection.traverse((child) => CommentPlugin.removeReflection(project, child, deletedIds));

const parent = <DeclarationReflection> reflection.parent;
parent.traverse((child: Reflection, property: TraverseProperty) => {
Expand Down Expand Up @@ -375,10 +389,7 @@ export class CommentPlugin extends ConverterComponent {
let id = reflection.id;
delete project.reflections[id];

for (let key in project.symbolMapping) {
if (project.symbolMapping.hasOwnProperty(key) && project.symbolMapping[key] === id) {
delete project.symbolMapping[key];
}
}
// keep track of the reflections that have been deleted
deletedIds.push(id);
}
}