Skip to content

Commit

Permalink
perf(scan): reduce childNotes scan level to avoid performance issue
Browse files Browse the repository at this point in the history
now at depth of 1, only parentNote get scanned; childNotes get scanned starting from depth of 2
  • Loading branch information
aidenlx committed Aug 28, 2021
1 parent 32a3874 commit 6b89405
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/scan.ts
Expand Up @@ -95,7 +95,8 @@ export const scanNote = (
} else if (
key === "childNotes" &&
(dive === undefined || dive) &&
Array.isArray(obj[key])
Array.isArray(obj[key]) &&
accu < depth - 1
) {
try {
value = obj.childNotes.map((v) => scan(v, true, accu + 1));
Expand Down Expand Up @@ -145,7 +146,8 @@ const getScanFunc = (depth: number) => {
} else if (
key === "childNotes" &&
(dive === undefined || dive) &&
Array.isArray(obj[key])
Array.isArray(obj[key]) &&
accu < depth - 1
) {
try {
value = (obj[key] as any[]).map((v) => scan(v, true, accu + 1));
Expand Down

0 comments on commit 6b89405

Please sign in to comment.