mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-26 01:23:13 +01:00
perf(channelserver): use package-level map for ignored opcodes
The ignored() function is called on every packet when debug logging is enabled. It was rebuilding a slice and map from scratch each time. Move to a package-level map initialized once at startup.
This commit is contained in:
@@ -279,22 +279,18 @@ func (s *Session) handlePacketGroup(pktGroup []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ignoredOpcodes = map[network.PacketID]struct{}{
|
||||||
|
network.MSG_SYS_END: {},
|
||||||
|
network.MSG_SYS_PING: {},
|
||||||
|
network.MSG_SYS_NOP: {},
|
||||||
|
network.MSG_SYS_TIME: {},
|
||||||
|
network.MSG_SYS_EXTEND_THRESHOLD: {},
|
||||||
|
network.MSG_SYS_POSITION_OBJECT: {},
|
||||||
|
}
|
||||||
|
|
||||||
func ignored(opcode network.PacketID) bool {
|
func ignored(opcode network.PacketID) bool {
|
||||||
ignoreList := []network.PacketID{
|
_, ok := ignoredOpcodes[opcode]
|
||||||
network.MSG_SYS_END,
|
return ok
|
||||||
network.MSG_SYS_PING,
|
|
||||||
network.MSG_SYS_NOP,
|
|
||||||
network.MSG_SYS_TIME,
|
|
||||||
network.MSG_SYS_EXTEND_THRESHOLD,
|
|
||||||
network.MSG_SYS_POSITION_OBJECT,
|
|
||||||
// network.MSG_MHF_SAVEDATA, // Temporarily enabled for debugging save issues
|
|
||||||
}
|
|
||||||
set := make(map[network.PacketID]struct{}, len(ignoreList))
|
|
||||||
for _, s := range ignoreList {
|
|
||||||
set[s] = struct{}{}
|
|
||||||
}
|
|
||||||
_, r := set[opcode]
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) logMessage(opcode uint16, data []byte, sender string, recipient string) {
|
func (s *Session) logMessage(opcode uint16, data []byte, sender string, recipient string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user