mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化网络层的GC
This commit is contained in:
@@ -99,8 +99,10 @@ func (p *MsgParser) Read(conn *TCPConn) ([]byte, error) {
|
||||
}
|
||||
|
||||
// data
|
||||
msgData := make([]byte, msgLen)
|
||||
//msgData := make([]byte, msgLen)
|
||||
msgData := makeByteSlice(int(msgLen))
|
||||
if _, err := io.ReadFull(conn, msgData); err != nil {
|
||||
releaseByteSlice(msgData)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -123,8 +125,8 @@ func (p *MsgParser) Write(conn *TCPConn, args ...[]byte) error {
|
||||
}
|
||||
|
||||
//msgLen -= 2
|
||||
msg := make([]byte, uint32(p.lenMsgLen)+msgLen)
|
||||
|
||||
//msg := make([]byte, uint32(p.lenMsgLen)+msgLen)
|
||||
msg := makeByteSlice(p.lenMsgLen+int(msgLen))
|
||||
// write len
|
||||
switch p.lenMsgLen {
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user