From d11ef91da41cb67570c33c37afb7deda19963a20 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Fri, 27 Jan 2023 15:38:01 -0800 Subject: [PATCH] Improve perf of diffed hook --- src/adapter/marks.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/adapter/marks.ts b/src/adapter/marks.ts index 1d09d861..c8798ee4 100644 --- a/src/adapter/marks.ts +++ b/src/adapter/marks.ts @@ -19,12 +19,14 @@ export function endMark(nodeName: string) { const name = markName(nodeName); const start = `${name}_diff`; const end = `${name}_diffed`; - if (performance.getEntriesByName(start).length > 0) { + try { performance.mark(end); performance.measure(name, start, end); + + performance.clearMarks(start); + performance.clearMarks(end); + } catch (e) { + // Do nothing } - performance.clearMarks(start); - performance.clearMarks(end); - performance.clearMeasures(name); } }