From fce64b166583b0bd74baca09c691c8330417d153 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 26 Sep 2018 10:19:38 +0200 Subject: [PATCH] reduce one pointer in TimedUserValidator --- proxy/vmess/vmess.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proxy/vmess/vmess.go b/proxy/vmess/vmess.go index 525f07e41..03ad2fabc 100644 --- a/proxy/vmess/vmess.go +++ b/proxy/vmess/vmess.go @@ -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 }