Skip to content

Commit ae6908d

Browse files
authored
perf: Avoid an extra function call and object clone during event emission (#1441)
performance: remove a nested function call and an object clone during event emission - rename `event` to `eventWithoutTime`, but maintain backwards compatibility - `eventWithTime` (with time) could be renamed to `event` in a future version This is an extension of PR #1339 authored by: mydea <mydea@users.noreply.github.com>
1 parent c0f83af commit ae6908d

File tree

5 files changed

+151
-177
lines changed

5 files changed

+151
-177
lines changed

.changeset/event-single-wrap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'rrweb': patch
3+
---
4+
5+
perf: Avoid an extra function call and object clone during event emission

packages/rrweb/src/record/iframe-manager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { genId, NodeType } from 'rrweb-snapshot';
33
import type { CrossOriginIframeMessageEvent } from '../types';
44
import CrossOriginIframeMirror from './cross-origin-iframe-mirror';
55
import { EventType, IncrementalSource } from '@rrweb/types';
6-
import type { eventWithTime, mutationCallBack } from '@rrweb/types';
6+
import type {
7+
eventWithTime,
8+
eventWithoutTime,
9+
mutationCallBack,
10+
} from '@rrweb/types';
711
import type { StylesheetManager } from './stylesheet-manager';
812

913
export class IframeManager {
@@ -16,7 +20,7 @@ export class IframeManager {
1620
new WeakMap();
1721
private mirror: Mirror;
1822
private mutationCb: mutationCallBack;
19-
private wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
23+
private wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;
2024
private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;
2125
private stylesheetManager: StylesheetManager;
2226
private recordCrossOriginIframes: boolean;
@@ -26,7 +30,7 @@ export class IframeManager {
2630
mutationCb: mutationCallBack;
2731
stylesheetManager: StylesheetManager;
2832
recordCrossOriginIframes: boolean;
29-
wrappedEmit: (e: eventWithTime, isCheckout?: boolean) => void;
33+
wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;
3034
}) {
3135
this.mutationCb = options.mutationCb;
3236
this.wrappedEmit = options.wrappedEmit;

0 commit comments

Comments
 (0)