-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize event ids by splitting them up by server/client and reliable/unreliable #143
base: 0.6.x
Are you sure you want to change the base?
Conversation
Event ids used to start at |
pub fn server_reliable_count(&self) -> usize { | ||
let reliable_count = self | ||
.evdecls | ||
.iter() | ||
.filter(|evdecl| evdecl.from == EvSource::Client && evdecl.evty == EvType::Reliable) | ||
.count(); | ||
|
||
reliable_count + self.fndecls.len() | ||
} | ||
|
||
pub fn server_unreliable_count(&self) -> usize { | ||
self.evdecls | ||
.iter() | ||
.filter(|evdecl| evdecl.from == EvSource::Client && evdecl.evty == EvType::Unreliable) | ||
.count() | ||
} | ||
|
||
pub fn client_reliable_count(&self) -> usize { | ||
let reliable_count = self | ||
.evdecls | ||
.iter() | ||
.filter(|evdecl| evdecl.from == EvSource::Server && evdecl.evty == EvType::Reliable) | ||
.count(); | ||
|
||
reliable_count + self.fndecls.len() | ||
} | ||
|
||
pub fn client_unreliable_count(&self) -> usize { | ||
self.evdecls | ||
.iter() | ||
.filter(|evdecl| evdecl.from == EvSource::Server && evdecl.evty == EvType::Unreliable) | ||
.count() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we doing this instead of having separate reliable and unreliable counts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows for more events before increasing the ids. Imagine 256 reliable client to server events and 256 reliable server to client events. With how I've done it, that only needs a u8. If we combined them, it would need a u16. It's possible to separate them because the events are one-way.
I might have misunderstood the question though.
Currently, all events and functions share event ids in the same pool. This is unnecessary and optimizing it will allow for more events/functions before needing to increase the bytes required for the event id.
To give an example, reliable events and functions are never sent through the unreliable remote. This means we can have separate pools of ids for reliable and unreliable.