Skip to content

Commit

Permalink
ref: Avoid cloning events to add timestamp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mydea committed Oct 25, 2023
1 parent 0b5df15 commit 20a46aa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ import {
} from './error-handler';

function wrapEvent(e: event): eventWithTime {
return {
...e,
timestamp: nowTimestamp(),
};
const eWithTime = e as eventWithTime;
eWithTime.timestamp = nowTimestamp();
return eWithTime;
}

declare global {
Expand Down

0 comments on commit 20a46aa

Please sign in to comment.