Skip to content

Commit 4f00566

Browse files
Do not freeze state in initialiseState() (#2846)
1 parent c1a3b95 commit 4f00566

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

src/models/event-timeline.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,6 @@ export class EventTimeline {
153153
throw new Error("Cannot initialise state after events are added");
154154
}
155155

156-
// We previously deep copied events here and used different copies in
157-
// the oldState and state events: this decision seems to date back
158-
// quite a way and was apparently made to fix a bug where modifications
159-
// made to the start state leaked through to the end state.
160-
// This really shouldn't be possible though: the events themselves should
161-
// not change. Duplicating the events uses a lot of extra memory,
162-
// so we now no longer do it. To assert that they really do never change,
163-
// freeze them! Note that we can't do this for events in general:
164-
// although it looks like the only things preventing us are the
165-
// 'status' flag, forwardLooking (which is only set once when adding to the
166-
// timeline) and possibly the sender (which seems like it should never be
167-
// reset but in practice causes a lot of the tests to break).
168-
for (const e of stateEvents) {
169-
Object.freeze(e);
170-
}
171-
172156
this.startState?.setStateEvents(stateEvents, { timelineWasEmpty });
173157
this.endState?.setStateEvents(stateEvents, { timelineWasEmpty });
174158
}

0 commit comments

Comments
 (0)