-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
🦋 Changeset detectedLatest commit: 065587a The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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.
76c72e1
to
065587a
Compare
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') |
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! |
… clone per event
… clone per event
I've gone a bit further with #1441 to avoid that extra function call at all |
And thank you for the contribution! (I couldn't make commits directly to this PR) |
(actually #1441 needs some more work) |
… clone per event
… clone per event
… clone per event
… clone per event
#1441 is ready now as a larger change than this one |
…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>
#1441 has been merged and I've tagged you in the merge commit, thank you for the PR! |
…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>
…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>
…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>
…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>
…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>
…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>
…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>
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.