homeserver icon indicating copy to clipboard operation
homeserver copied to clipboard

Spliting Room::create() into small functions

Open farodin91 opened this issue 9 years ago • 3 comments

Room::create is more than 350 lines of code. This helps make it easier to fix bugs in the function.

farodin91 avatar Jan 10 '17 19:01 farodin91

That's true but it's easy code; most of the lines are declarations of event structs. The biggest part of the function is the pattern matching on initial state which cannot be split (maybe a new function?). The only improvement I see is to remove the flags is_something_set and just generate the events in the order specified by the spec. That will generate a few extra events that will be overwritten; that's why the flags exist.

mujx avatar Jan 10 '17 20:01 mujx

I think of the following if creation_options.initial_state.is_some() {.

farodin91 avatar Jan 10 '17 20:01 farodin91

Moving part in into private function would help reduce doubling, but make it much easier to read since every function has a name and a small doc.

farodin91 avatar Jan 10 '17 20:01 farodin91