Mercurial > gemma
changeset 1323:3c914bc670a2
Avoid copying session data while deserializing from store.
This involed copying a mutex which would technical be not
correct if the mutex would be used at this time, which it is
not. go vet was not happy about this even if its not
a problem. Not copying the data makes it a bit faster, though.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 24 Nov 2018 17:08:56 +0100 |
parents | 176c42053562 |
children | 19108851af13 |
files | pkg/auth/session.go |
diffstat | 1 files changed, 5 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/auth/session.go Sat Nov 24 16:55:40 2018 +0100 +++ b/pkg/auth/session.go Sat Nov 24 17:08:56 2018 +0100 @@ -90,17 +90,15 @@ func (s *Session) deserialize(r io.Reader) error { - var session Session - var n uint32 rd := misc.BinReader{Reader: r, Err: nil} - rd.ReadBin(&session.ExpiresAt) - rd.ReadString(&session.User) + rd.ReadBin(&s.ExpiresAt) + rd.ReadString(&s.User) rd.ReadBin(&n) - session.Roles = make(Roles, n) + s.Roles = make(Roles, n) for i := uint32(0); n > 0 && i < n; i++ { - rd.ReadString(&session.Roles[i]) + rd.ReadString(&s.Roles[i]) } if rd.Err != nil { @@ -121,9 +119,7 @@ return err } - session.access = t - - *s = session + s.access = t return nil }