Skip to content

Commit

Permalink
Merge pull request #450 from preactjs/improve-perf
Browse files Browse the repository at this point in the history
Improve perf of diffed hook
  • Loading branch information
marvinhagemeister authored Apr 25, 2024
2 parents 2c95133 + d11ef91 commit 9275ceb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/adapter/marks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 9275ceb

Please sign in to comment.