Skip to content

Commit 118362f

Browse files
committed
ref: Avoid cloning events to add timestamp
We are always passing in fresh objects to this method, so instead of cloning this into a new object, we can just put the `timestamp` on the given object directly and return it, saving a bit of processing cost.
1 parent ab97f8f commit 118362f

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/rrweb/src/record/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ import {
5353
} from './error-handler';
5454

5555
function wrapEvent(e: event): eventWithTime {
56-
return {
57-
...e,
58-
timestamp: nowTimestamp(),
59-
};
56+
const eWithTime = e as eventWithTime;
57+
eWithTime.timestamp = nowTimestamp();
58+
return eWithTime;
6059
}
6160

6261
declare global {

0 commit comments

Comments
 (0)