1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-05-19 18:59:08 -04:00

reduce memory allocation in mux

This commit is contained in:
Darien Raymond
2017-10-27 11:40:18 +02:00
parent 3b53fd7cd6
commit a1cf299848
2 changed files with 13 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ type SessionManager struct {
func NewSessionManager() *SessionManager {
return &SessionManager{
count: 0,
sessions: make(map[uint16]*Session, 32),
sessions: make(map[uint16]*Session, 16),
}
}
@@ -58,6 +58,10 @@ func (m *SessionManager) Add(s *Session) {
m.Lock()
defer m.Unlock()
if m.closed {
return
}
m.sessions[s.ID] = s
}
@@ -65,6 +69,10 @@ func (m *SessionManager) Remove(id uint16) {
m.Lock()
defer m.Unlock()
if m.closed {
return
}
delete(m.sessions, id)
}
@@ -111,7 +119,7 @@ func (m *SessionManager) Close() {
s.output.Close()
}
m.sessions = make(map[uint16]*Session)
m.sessions = nil
}
type Session struct {