Open UkoeHB opened 8 months ago
But I would probably remove channel_id from ChannelConfig and automatically assign it based on the index. This way we ensure that channels have sequenced IDs.
That would be a breaking change, this is just a refactor PR.
Problem
Currently you need a
HashMap
lookup to access channels in clients. On the server these hashmaps are accessed for every packet received.Solution
Use a
Vec
to store the channels so lookups are fast. Channels should be generated in monotonically increasing order, so in general there won't be any empty entries. Even if there are empty entries, at most 256 channels can be created, so the memory cost of bad channel assignment is not significant.Follow-up