mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-17 14:57:44 -05:00
reduce one pointer in TimedUserValidator
This commit is contained in:
parent
9d646d6039
commit
fce64b1665
@ -23,7 +23,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type user struct {
|
type user struct {
|
||||||
user *protocol.MemoryUser
|
user protocol.MemoryUser
|
||||||
lastSec protocol.Timestamp
|
lastSec protocol.Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error {
|
|||||||
nowSec := time.Now().Unix()
|
nowSec := time.Now().Unix()
|
||||||
|
|
||||||
uu := &user{
|
uu := &user{
|
||||||
user: u,
|
user: *u,
|
||||||
lastSec: protocol.Timestamp(nowSec - cacheDurationSec),
|
lastSec: protocol.Timestamp(nowSec - cacheDurationSec),
|
||||||
}
|
}
|
||||||
v.users = append(v.users, uu)
|
v.users = append(v.users, uu)
|
||||||
@ -136,7 +136,9 @@ func (v *TimedUserValidator) Get(userHash []byte) (*protocol.MemoryUser, protoco
|
|||||||
copy(fixedSizeHash[:], userHash)
|
copy(fixedSizeHash[:], userHash)
|
||||||
pair, found := v.userHash[fixedSizeHash]
|
pair, found := v.userHash[fixedSizeHash]
|
||||||
if found {
|
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
|
return nil, 0, false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user