diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-11-16 15:44:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 15:44:53 +0000 |
commit | 20a01bceb2869c810932eac217d96dc221953685 (patch) | |
tree | 639cd8656282ae231a46531f063d7d010320a582 /cmd | |
parent | d8b526b603683879c012972707cdce44fff3c802 (diff) |
Pass pointers to events — reloaded (#1583)
* Pass events as pointers
* Fix lint errors
* Update gomatrixserverlib
* Update gomatrixserverlib
* Update to matrix-org/gomatrixserverlib#240
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/create-room-events/main.go | 2 | ||||
-rw-r--r-- | cmd/resolve-state/main.go | 17 | ||||
-rw-r--r-- | cmd/syncserver-integration-tests/main.go | 2 |
3 files changed, 6 insertions, 15 deletions
diff --git a/cmd/create-room-events/main.go b/cmd/create-room-events/main.go index afe97464..23b44193 100644 --- a/cmd/create-room-events/main.go +++ b/cmd/create-room-events/main.go @@ -123,7 +123,7 @@ func buildAndOutput() gomatrixserverlib.EventReference { } // Write an event to the output. -func writeEvent(event gomatrixserverlib.Event) { +func writeEvent(event *gomatrixserverlib.Event) { encoder := json.NewEncoder(os.Stdout) if *format == "InputRoomEvent" { var ire api.InputRoomEvent diff --git a/cmd/resolve-state/main.go b/cmd/resolve-state/main.go index 9fb14f05..a622fbf2 100644 --- a/cmd/resolve-state/main.go +++ b/cmd/resolve-state/main.go @@ -80,9 +80,9 @@ func main() { } authEventIDMap := make(map[string]struct{}) - eventPtrs := make([]*gomatrixserverlib.Event, len(eventEntries)) + events := make([]*gomatrixserverlib.Event, len(eventEntries)) for i := range eventEntries { - eventPtrs[i] = &eventEntries[i].Event + events[i] = eventEntries[i].Event for _, authEventID := range eventEntries[i].AuthEventIDs() { authEventIDMap[authEventID] = struct{}{} } @@ -99,18 +99,9 @@ func main() { panic(err) } - authEventPtrs := make([]*gomatrixserverlib.Event, len(authEventEntries)) + authEvents := make([]*gomatrixserverlib.Event, len(authEventEntries)) for i := range authEventEntries { - authEventPtrs[i] = &authEventEntries[i].Event - } - - events := make([]gomatrixserverlib.Event, len(eventEntries)) - authEvents := make([]gomatrixserverlib.Event, len(authEventEntries)) - for i, ptr := range eventPtrs { - events[i] = *ptr - } - for i, ptr := range authEventPtrs { - authEvents[i] = *ptr + authEvents[i] = authEventEntries[i].Event } fmt.Println("Resolving state") diff --git a/cmd/syncserver-integration-tests/main.go b/cmd/syncserver-integration-tests/main.go index a11dd2a0..cbbcaa7e 100644 --- a/cmd/syncserver-integration-tests/main.go +++ b/cmd/syncserver-integration-tests/main.go @@ -103,7 +103,7 @@ func clientEventJSONForOutputRoomEvent(outputRoomEvent string) string { if err := json.Unmarshal([]byte(outputRoomEvent), &out); err != nil { panic("failed to unmarshal output room event: " + err.Error()) } - clientEvs := gomatrixserverlib.ToClientEvents([]gomatrixserverlib.Event{ + clientEvs := gomatrixserverlib.ToClientEvents([]*gomatrixserverlib.Event{ out.NewRoomEvent.Event.Event, }, gomatrixserverlib.FormatSync) b, err := json.Marshal(clientEvs[0]) |