Skip to content

Commit

Permalink
Stop passing state event IDs around
Browse files Browse the repository at this point in the history
This yields a further improvement as we don't need to lookup those
events, instead they get pulled from state.

See discussion on: matrix-org#13210
  • Loading branch information
Fizzadar committed Jul 11, 2022
1 parent 30411fd commit faf634c
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ async def create_room(
(
last_stream_id,
last_sent_event_id,
state_event_ids,
depth,
) = await self._send_events_for_new_room(
requester,
Expand Down Expand Up @@ -915,11 +914,9 @@ async def create_room(
},
ratelimit=False,
prev_event_ids=[last_sent_event_id],
state_event_ids=state_event_ids.copy(),
depth=depth,
)
last_sent_event_id = name_event.event_id
state_event_ids.append(name_event.event_id)
depth += 1

if "topic" in config:
Expand All @@ -938,11 +935,9 @@ async def create_room(
},
ratelimit=False,
prev_event_ids=[last_sent_event_id],
state_event_ids=state_event_ids.copy(),
depth=depth,
)
last_sent_event_id = topic_event.event_id
state_event_ids.append(topic_event.event_id)
depth += 1

# we avoid dropping the lock between invites, as otherwise joins can
Expand All @@ -969,10 +964,8 @@ async def create_room(
content=content,
new_room=True,
prev_event_ids=[last_sent_event_id],
state_event_ids=state_event_ids.copy(),
depth=depth,
)
state_event_ids.append(last_sent_event_id)
depth += 1

for invite_3pid in invite_3pid_list:
Expand Down Expand Up @@ -1034,7 +1027,6 @@ async def _send_events_for_new_room(
event_keys = {"room_id": room_id, "sender": creator_id, "state_key": ""}

depth = 1
state_event_ids: List[str] = []
last_sent_event_id: Optional[str] = None

def create(etype: str, content: JsonDict, **kwargs: Any) -> JsonDict:
Expand Down Expand Up @@ -1186,7 +1178,7 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int:
content={"algorithm": RoomEncryptionAlgorithms.DEFAULT},
)

return last_sent_stream_id, last_sent_event_id, state_event_ids, depth
return last_sent_stream_id, last_sent_event_id, depth

def _generate_room_id(self) -> str:
"""Generates a random room ID.
Expand Down

0 comments on commit faf634c

Please sign in to comment.