1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

reduce one pointer in TimedUserValidator

This commit is contained in:
Darien Raymond 2018-09-26 10:19:38 +02:00
parent 9d646d6039
commit fce64b1665
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -23,7 +23,7 @@ const (
)
type user struct {
user *protocol.MemoryUser
user protocol.MemoryUser
lastSec protocol.Timestamp
}
@ -119,7 +119,7 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error {
nowSec := time.Now().Unix()
uu := &user{
user: u,
user: *u,
lastSec: protocol.Timestamp(nowSec - cacheDurationSec),
}
v.users = append(v.users, uu)
@ -136,7 +136,9 @@ func (v *TimedUserValidator) Get(userHash []byte) (*protocol.MemoryUser, protoco
copy(fixedSizeHash[:], userHash)
pair, found := v.userHash[fixedSizeHash]
if found {
return pair.user.user, protocol.Timestamp(pair.timeInc) + v.baseTime, true
var user protocol.MemoryUser
user = pair.user.user
return &user, protocol.Timestamp(pair.timeInc) + v.baseTime, true
}
return nil, 0, false
}