Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Avoid cloning events to add timestamp #1339

Closed

Conversation

mydea
Copy link
Contributor

@mydea mydea commented Oct 25, 2023

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.

@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2023

🦋 Changeset detected

Latest commit: 065587a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/types Patch
@rrweb/web-extension Patch
rrvideo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.
@mydea mydea force-pushed the fn-upstream/avoid-event-cloning branch from 76c72e1 to 065587a Compare October 25, 2023 12:28
@eoghanmurray
Copy link
Contributor

This is modifying the underlying object? Are you sure there aren't any typing problems with this, or possible knock on problems? (I can't think of anything over and above it being 'less clean')

@mydea
Copy link
Contributor Author

mydea commented Feb 27, 2024

Yes, but as far as I can tell we are always passing in a fresh object into this anyhow. We've been running this on our fork at Sentry without problems (as far as I can tell...) for some time now!

eoghanmurray added a commit to eoghanmurray/rrweb that referenced this pull request Apr 9, 2024
eoghanmurray added a commit to eoghanmurray/rrweb that referenced this pull request Apr 9, 2024
@eoghanmurray
Copy link
Contributor

I've gone a bit further with #1441 to avoid that extra function call at all

@eoghanmurray
Copy link
Contributor

And thank you for the contribution!

(I couldn't make commits directly to this PR)

@eoghanmurray
Copy link
Contributor

(actually #1441 needs some more work)

eoghanmurray added a commit to eoghanmurray/rrweb that referenced this pull request Apr 10, 2024
eoghanmurray added a commit to eoghanmurray/rrweb that referenced this pull request Apr 10, 2024
eoghanmurray added a commit to eoghanmurray/rrweb that referenced this pull request Apr 10, 2024
eoghanmurray added a commit to eoghanmurray/rrweb that referenced this pull request Apr 10, 2024
@eoghanmurray
Copy link
Contributor

#1441 is ready now as a larger change than this one

eoghanmurray added a commit that referenced this pull request Apr 19, 2024
…sion (#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>
@eoghanmurray
Copy link
Contributor

#1441 has been merged and I've tagged you in the merge commit, thank you for the PR!

billyvg pushed a commit to getsentry/rrweb that referenced this pull request Apr 19, 2024
…sion (rrweb-io#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 rrweb-io#1339 authored by: mydea <mydea@users.noreply.github.com>
billyvg pushed a commit to getsentry/rrweb that referenced this pull request Apr 19, 2024
…sion (rrweb-io#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 rrweb-io#1339 authored by: mydea <mydea@users.noreply.github.com>
billyvg pushed a commit to getsentry/rrweb that referenced this pull request Apr 19, 2024
…sion (rrweb-io#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 rrweb-io#1339 authored by: mydea <mydea@users.noreply.github.com>
billyvg added a commit to getsentry/rrweb that referenced this pull request Apr 22, 2024
…event emission (#180)

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 rrweb-io#1339 authored by: mydea
<mydea@users.noreply.github.com>
jaj1014 pushed a commit to pendo-io/rrweb that referenced this pull request Apr 30, 2024
…sion (rrweb-io#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 rrweb-io#1339 authored by: mydea <mydea@users.noreply.github.com>
jxiwang pushed a commit to amplitude/rrweb that referenced this pull request Jul 31, 2024
…sion (rrweb-io#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 rrweb-io#1339 authored by: mydea <mydea@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants