Skip to content

Commit

Permalink
See rrweb-io#1339 - perf: remove a nested function call and an object…
Browse files Browse the repository at this point in the history
… clone per event
  • Loading branch information
eoghanmurray committed Apr 10, 2024
1 parent 3d1877c commit 5ae5adf
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 175 deletions.
5 changes: 5 additions & 0 deletions .changeset/event-single-wrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrweb': patch
---

perf: Avoid an extra function call and object clone during event emission
6 changes: 3 additions & 3 deletions packages/rrweb/src/record/iframe-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { genId, NodeType } from 'rrweb-snapshot';
import type { CrossOriginIframeMessageEvent } from '../types';
import CrossOriginIframeMirror from './cross-origin-iframe-mirror';
import { EventType, IncrementalSource } from '@rrweb/types';
import type { eventWithTime, mutationCallBack } from '@rrweb/types';
import type { eventWithTime, eventWithoutTime, mutationCallBack } from '@rrweb/types';
import type { StylesheetManager } from './stylesheet-manager';

export class IframeManager {
Expand All @@ -16,7 +16,7 @@ export class IframeManager {
new WeakMap();
private mirror: Mirror;
private mutationCb: mutationCallBack;
private wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
private wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;
private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;
private stylesheetManager: StylesheetManager;
private recordCrossOriginIframes: boolean;
Expand All @@ -26,7 +26,7 @@ export class IframeManager {
mutationCb: mutationCallBack;
stylesheetManager: StylesheetManager;
recordCrossOriginIframes: boolean;
wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;
}) {
this.mutationCb = options.mutationCb;
this.wrappedEmit = options.wrappedEmit;
Expand Down
Loading

0 comments on commit 5ae5adf

Please sign in to comment.